๐Ÿ’กโšกBeginner

Find Quotient and Remainder

Division operations

Find the quotient and remainder of division using / and % operators.

Program Code

quotient_remainder.c
C
1#include <stdio.h>
2
3int main() {
4 int dividend, divisor;
5
6 printf("Enter dividend: ");
7 scanf("%d", &dividend);
8
9 printf("Enter divisor: ");
10 scanf("%d", &divisor);
11
12 if (divisor == 0) {
13 printf("Error: Division by zero!\n");
14 return 1;
15 }
16
17 int quotient = dividend / divisor;
18 int remainder = dividend % divisor;
19
20 printf("\n%d รท %d\n", dividend, divisor);
21 printf("Quotient = %d\n", quotient);
22 printf("Remainder = %d\n", remainder);
23 printf("\nVerification: %d = %d ร— %d + %d\n",
24 dividend, divisor, quotient, remainder);
25
26 return 0;
27}
Output

Enter dividend: 25

Enter divisor: 7

ย 

25 รท 7

Quotient = 3

Remainder = 4

ย 

Verification: 25 = 7 ร— 3 + 4

Want to Learn More?

Explore our comprehensive tutorials for in-depth explanations of C programming concepts.

Browse Tutorials
Back to All Examples