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
Subtract two numbers using method overriding Program 1
PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…
Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…
Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…
Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…
How to write a program to convert Fahrenheit into Celsius In this article, we will…
This website uses cookies.