C Program to compute Quotient and Remainder

Problem

Write a program in C to calculate the quotient and remainder and display it on the screen.

How to compute quotient and remainder in C ?

#include <stdio.h>
int main()
{
    // Abundantcode - program to calculate quotient and remainder
    int dividend, divisor, quotient, rem;

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

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

    quotient = dividend / divisor;

    rem = dividend % divisor;

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

    return 0;
}

Output

Enter dividend: 8                                     
Enter divisor: 3                                  
Quotient = 2                                         
Remainder = 2

%d bloggers like this: