C Program to Find Quotient and Remainder

Write a C program to find quotient and remainder. This C example allows the user to enter two integer values and uses the / and % operator to compute quotient and remainder.

#include <stdio.h>

int main()
{
    int number1, number2;
    float quotient, remainder;
    
    printf("Enter the Number to perform Division = ");
    scanf("%d",&number1);

    printf("Enter the Divisor Number = ");
    scanf("%d",&number2);
    
    quotient = number1 / number2;

    remainder = number1 % number2;

    printf("The Quotient of %d and %d   = %.2f", number1, number2, quotient); 
    printf("\nThe Remainder of %d and %d = %.2f\n", number1, number2, remainder);
}
C Program to Find Quotient and Remainder

In this C program, calcQuotient and calcRemainder functions accept two integer values and find the quotient and remainder.

#include <stdio.h>

float calcQuotient(int a, int b) {
    return a / b;
}

float calcRemainder(int a, int b) {
    return a % b;
}

int main()
{
    int number1, number2;
    float quotient, remainder;
    
    printf("Enter the Number to perform Division = ");
    scanf("%d",&number1);

    printf("Enter the Divisor Number = ");
    scanf("%d",&number2);
    
    quotient = calcQuotient(number1, number2);

    remainder = calcRemainder(number1, number2);

    printf("The Quotient of %d and %d = %.2f\n", number1, number2, quotient); 
    printf("The Remainder of %d and %d = %.2f\n", number1, number2, remainder);
    
    return 0;
}
Enter the Number to perform Division = 229
Enter the Divisor Number = 5
The Quotient of 229 and 5 = 45.00
The Remainder of 229 and 5 = 4.00