C Program to Find Quotient and Remainder

Write a C program to find the quotient and remainder. This example allows the user to enter two integer values and uses the / and % operators to compute the 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, the two user-defined functions accept two integer values and find the quotient and remainder.

#include <stdio.h>

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

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

int main()
{
    int num1, num2;
    float quot, rem;
    
    printf("Enter the Number = ");
    scanf("%d",&number1);

    printf("Enter the Divisor Number = ");
    scanf("%d",&number2);
    
    quot = calcQuot(num1, num2);

    rem = calcRem(num1, num2);

    printf("The Quotient of %d and %d = %.2f\n", num1, num2, quot); 
    printf("The Remainder of %d and %d = %.2f\n", num1, num2, rem);
    
    return 0;
}
Enter the Number = 229
Enter the Divisor Number = 5
The Quotient of 229 and 5 = 45.00
The Remainder of 229 and 5 = 4.00

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.