Question

Write a program that takes in two integers and finds the remainder of the first integer...

Write a program that takes in two integers and finds the remainder of the first integer divided by the second integer, WITHOUT USING THE MOD OPERATOR. You may not use the modulus operator to do this, you are to use a looping construct to do this.

C++

0 0
Add a comment Improve this question Transcribed image text
Answer #1
//#include <iostream>
#include <iostream>
using namespace std;

int main() {
   int a,b,t;
   
   cout<<"Enter first value: ";
   cin>>a;
   
   cout<<"Enter second value: ";
   cin>>b;
   
   t = a;
   while(t>=b){
      t = t - b;
   }
   
   cout<<"Reminder = "<<t<<endl;
   
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
Write a program that takes in two integers and finds the remainder of the first integer...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program which takes in two integers and produces their quotient. Here is a sample...

    Write a program which takes in two integers and produces their quotient. Here is a sample of their output: If you input 135 and 12, the output should read: 135 divided by 12 is 11 remainder 3. using java, netbeans

  • Exercise 9.2 Write a Python program that collects from the user a single integer. Have the...

    Exercise 9.2 Write a Python program that collects from the user a single integer. Have the program print “EVEN” if the integer is divisible by 2, and “ODD” if the integer is not divisible by two. [Use the % operator to compute the two’s modulus (remainder of division by two)] Exercise 9.3 Write a Python program that collects from the user two integers. Have the program print “Yes” if the two integers are BOTH greater than 10. Do nothing if...

  • How can I construct a program (pseudocode and flowchart with flowgorithm) to report the remainder of...

    How can I construct a program (pseudocode and flowchart with flowgorithm) to report the remainder of N/D division, where N and D are integers using the mod (or modulus or modulo) operator or function) and improve the code to test if N is an odd number.

  • Write an assembler program that asks the user (as shown below) for two integers and a...

    Write an assembler program that asks the user (as shown below) for two integers and a single character representing the arithmetic operations: addition, subtraction, multiplication and integer division (displays both quotient and remainder). Perform the requested operation on the operands and display the result as specified below. Assume SIGNED NUMBERS. The program should not divide by 0! If the user attempts to divide by 0, display the error message: "Cannot divide by zero." If this error occurs, the program should...

  • Write a program whose input is two integers, and whose output is the first integer

    5.20 (Ch 5) HW: Output range with increment of 10 Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 10 as long as the value is less than or equal to the second integer Ex: If the input is: -15 30 Then the output is: 15 -5 5 15 25 Ex: If the second integer is less than the first as in 20 5, the output is: Second integer can't be less than the...

  • Write a program to subtract large unsigned integers. Your program should prompt and read in two...

    Write a program to subtract large unsigned integers. Your program should prompt and read in two large unsigned integers. The two large integers should be stored arrays, one array for each integer. The integers should be stored with one digit per location in the two arrays. The first integer should be no smaller than the second. Your program should subtract the second integer from the first. The result should be stored in an array, again one digit per location in...

  • Write a program to subtract large unsigned integers. Your program should prompt and read in two...

    Write a program to subtract large unsigned integers. Your program should prompt and read in two large unsigned integers. The two large integers should be stored arrays, one array for each integer. The integers should be stored with one digit per location in the two arrays. The first integer should be no smaller than the second. Your program should subtract the second integer from the first. The result should be stored in an array, again one digit per location in...

  • the user should be prompted to enter an integer and then your program will produce another...

    the user should be prompted to enter an integer and then your program will produce another integer depending on whether the input was even or odd. The following is an example of what you might see when you run the program; the input you type is shown in green (press Enter at the end of a line), and the output generated by the program is shown in black text. Enter an integer: 1234 Number is even, taking every other digit...

  • Write a program that reads an integer k from user and finds the number of elements...

    Write a program that reads an integer k from user and finds the number of elements that are divisible by k in the file assignment4.txt. A number n is divisible by k if n = kx for some integer x > 0. You can use the mod operator % to test for divisibility. The file assign4.txt has integer values in the range [0,100 ]. You should use end-of-file controlled loop for this problem. Sample execution is given below. Assume the...

  • Draw the flowchart of the program that will find the remainder of a positive integer entered...

    Draw the flowchart of the program that will find the remainder of a positive integer entered by the user with another integer to be entered by the user, without using the remaining operator (%).

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT