Given two numbers A and B. The task is to write a program to find the quotient and remainder of these two numbers when A is divided by B.
Input: A = 2, B = 6 Output: Quotient = 0, Remainder = 2 Input: A = 17, B = 5 Output: Quotient = 3, Remainder = 2
In the below program, to find the quotient and remainder of the two numbers, the user is first asked to enter two numbers. The inputs are scanned using the scanf() function and stored in the variables and . Then, the variables and are divided using the arithmetic operator to get the quotient as result stored in the variable quotient; and using the arithmetic operator % to get the remainder as result stored in the variable remainder.
Below is the programs to find the quotient and remainder of two numbers:
Enter two numbers A and B : 17 5 Quotient when A/B is: 3 Remainder when A/B is: 2
Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.