C Program for Division
C Program for explaining the division operation, for getting quotient and remainder.
PROGRAM:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#include<stdio.h> #include<conio.h> int main() { int x,y; int result1,result2; printf("\n Enter the dividend : "); scanf("%d",&x); printf("\n Enter the divisor: "); scanf("%d",&y); result1 = x/y; //it gives the quotient result2 = x%y; //it gives remainder printf("\n The Quotient is: %d ",result1); printf("\n The Remainder is: %d ",result2); getch(); return 0; } |
Sample Output: ( using GNU GCC Compiler with Code Blocks IDE )
Enter the dividend: 26
Enter the divisor: 5
The Quotient is: 5
The Remainder is: 1