Compute Quotient and Remainder
Table of Contents
In this tutorial, we will discuss the Program to Compute Quotient and Remainder in C
In this post, we are going to learn how to find quotient and remainder using two numbers via different 3 ways in C.
Program 1
#include <stdio.h>
#include <stdlib.h>
int main()
{
int dividend=200,divisor=12;
int quotient,remainder;
quotient=dividend/divisor; // / operator use to compute quotient
remainder=dividend%divisor; // % operator use to compute remainder
printf("Quotient = %d\n",quotient);
printf("Remainder = %d\n",remainder);
getch();
return 0;
} When the above code is executed, it produces the following result
Quotient = 16 Remainder = 8
In this program,
Program 2
#include <stdio.h>
#include <stdlib.h>
int main()
{
int dividend,divisor;
int quotient,remainder;
printf("Enter dividend: " );
scanf("%d",÷nd);
printf("Enter divisor: " );
scanf("%d",&divisor);
quotient=dividend/divisor; // / operator use to compute quotient
remainder=dividend%divisor; // % operator use to compute remainder
printf("Quotient = %d\n",quotient);
printf("Remainder = %d\n",remainder);
getch();
return 0;
}
When the above code is executed, it produces the following result
Enter dividend: 200 Enter divisor: 15 Quotient = 13 Remainder = 5
Program 3
#include <stdio.h>
#include <stdlib.h>
int findQuitient(int a, int b){
return a/b;
}
int findRemainder(int a, int b){
return a%b;
}
int main()
{
int dividend,divisor;
printf("Enter dividend: " );
scanf("%d",÷nd);
printf("Enter divisor: " );
scanf("%d",&divisor);
printf("Quotient = %d\n",findQuitient(dividend,divisor));
printf("Remainder = %d\n",findRemainder(dividend,divisor));
getch();
return 0;
}
When the above code is executed, it produces the following result
Enter dividend: 230 Enter divisor: 15 Quotient = 15 Remainder = 5
Approach
Program 4
#include <stdio.h>
#include <stdlib.h>
//user define function for find quotient
void findQuotient(int a, int b){
int Quotient= a/b;
printf("Quotient = %d",Quotient);
}
//user define function for find remainder
void findRemainder(int a, int b){
int Remainder =a%b;
printf("\nRemainder %d",Remainder);
}
int main()
{
int dividend,divisor;
//integer variable declaration
printf("Enter dividend: ") ;
//Ask input from the user for dividend
scanf("%d",÷nd);
//Reading the input
printf("Enter divisor: ") ;
//Ask input from the user for divisor
scanf("%d",&divisor);
//Reading the input
findQuotient(dividend,divisor);
//Call the function for display quotient
findRemainder(dividend,divisor);
//Call the function for display remainder
getch();
return 0;
}
When the above code is executed, it produces the following result
Enter dividend: 54 Enter divisor: 6 Quotient = 9 Remainder = 0
Program 5
#include <stdio.h>
#include <stdlib.h>
//user define function for find quotient
void findQuotient(int a, int b){
int Quotient= a/b;
printf("Quotient = %d",Quotient);
}
//user define function for find remainder
void findRemainder(int a, int b){
int Remainder =a%b;
printf("\nRemainder %d",Remainder);
}
int main()
{
int dividend=190,divisor=7;
//integer variable declaration
findQuotient(dividend,divisor);
//Call the function for display quotient
findRemainder(dividend,divisor);
//Call the function for display remainder
getch();
return 0;
}
When the above code is executed, it produces the following result
Quotient = 24 Remainder = 2
Suggested for you
Data type in C language
Variable in C language
Similar post
Python Program to Compute Quotient and Remainder
Java Program to Compute Quotient and Remainder
C++ Program to Compute Quotient and Remainder
Multiply two numbers in Java using scanner| 5 different ways In this article, we will…
5 Different ways to Divide two numbers in Java using scanner In this article, we…
Learn 8 Ways to Subtract Two Numbers Using Methods in Java In this article, we…
10 ways to subtract two numbers in Java In this article, we will discuss the…
Java Code Examples – Multiply Two Numbers in 5 Easy Ways In this article, we…
How to Divide two numbers in Java| 5 different ways In this article, we will…
This website uses cookies.