Google News
logo
C Program to Find Quotient and Remainder
In the following example of C program to find the quotient and remainder of two integers :
Program :
#include <stdio.h>

int main() {
    int dividend, divisor, quotient, remainder;

    printf("Enter dividend: ");
    scanf("%d", &dividend);

    printf("Enter divisor: ");
    scanf("%d", &divisor);

    quotient = dividend / divisor;
    remainder = dividend % divisor;

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

    return 0;
}
Output :
Enter dividend: 18
Enter divisor: 4
Quotient = 4
Remainder = 2
In this program, the user is prompted to enter the dividend and divisor. The quotient is calculated using the division operator (/) and the remainder is calculated using the modulus operator (%). The quotient and remainder are then printed to the console.