top of page
Search

Write a C Program to Compute Quotient and Remainder?



Write a C Program to Compute Quotient and Remainder?

#include <stdio.h>

int main()

{

int dividend, divisor, quotient, remainder;

printf("Enter dividend: ");

scanf("%d", &dividend);

printf("Enter divisor: ");

scanf("%d", &divisor);

// Computes quotient

quotient = dividend / divisor;

// Computes remainder

remainder = dividend % divisor;

printf("Quotient = %d\n", quotient);

printf("Remainder = %d", remainder);

return 0;

}


Output:

Enter dividend: 25

Enter divisor: 4

Quotient = 6

Remainder = 1


Explanation:

This is a simple program where the user enters two integers which are stored as variable dividend and divisor respectively. Then the quotient is calculated using the division/operator and the result is stored in the variable quotient.

Similarly, the remainder is calculated using modulus % operator and stored in the remainder variable.

Finally, the quotient and remainder are displayed using printf() function.


For Video Explanations Check Out Our Playlist on Youtube HERE.


36 views
bottom of page