C Program to Find Quotient and Remainder of Two Integers Entered by User
In this program, user is asked to enter two integers(dividend and divisor) and this program will compute the quotient and remainder and display it.
Source Code
/* C Program to compute remainder and quotient */ #include <stdio.h> int main(){ int dividend, divisor, quotient, remainder; printf("Enter dividend: "); scanf("%d",÷nd); printf("Enter divisor: "); scanf("%d",&divisor); quotient=dividend/divisor; /* Computes quotient */ remainder=dividend%divisor; /* Computes remainder */ printf("Quotient = %d\n",quotient); printf("Remainder = %d",remainder); return 0; }
Output
Enter dividend: 25 Enter divisor: 4 Quotient = 6 Remainder = 1
Explanation
This program takes two integers(dividend and divisor) from user and stores it in variable dividend and divisor. Then, quotient and remainder is calculated and stored in variable quotient and remainder. Operator / is used for calculation of quotient and % is used for calculating remainder. Learn more about divison(/) and modulo division(%) operator in C programming
0 comments:
Post a Comment