![]() |
VOOZH | about |
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.
Examples:
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 A and B. Then, the variables A and B are divided using the arithmetic operator / to get the quotient as the result stored in the variable quotient; and using the arithmetic operator % to get the remainder as the result stored in the variable remainder.
Below are the programs to find the quotient and remainder of two numbers:
Enter two numbers A and B: Quotient when A / B is: 3 Remainder when A / B is: 2
Time Complexity: O(1)
Auxiliary Space: O(1)
Below is the C program to find the quotient and remainder using loops:
Quotient when A/B is: 3 Remainder when A/B is: 2
Below is the program to find the quotient and remainder of a number using functions:
Quotient when A/B is: 3 Remainder when A/B is: 2