ADVERTISEMENT
ADVERTISEMENT

C program to find quotient and remainder

This program will read dividend and divisor and find the quotient and remainder of two numbers in c language.

How to get quotient and remainder?

Binary operator divide (/) returns the quotient, let suppose if dividend is 10 and divisor is 3, then quotient will be 3.

Binary operator modulus (%) returns the remainder, let suppose if dividend is 10 and divisor is 3, then remainder will be 1.

In this c program, we will read dividend and divisor and find the quotient, remainder.

ADVERTISEMENT

Program to find quotient and remainder in C

#include <stdio.h>

int main()
{
	int dividend, divisor;
	int quotient, remainder;
	
	printf("Enter dividend: ");
	scanf("%d",&dividend);
	printf("Enter divisor: ");
	scanf("%d",&divisor);
	
	quotient= dividend/divisor;
	remainder= dividend%divisor;
	
	printf("quotient: %d, remainder: %d\n",quotient,remainder);
	
	return 0;
}

Output

First run:
Enter dividend: 10
Enter divisor: 3
quotient: 3, remainder: 1 

Second run:
Enter dividend: 10
Enter divisor: 2
quotient: 5, remainder: 0 

Third run:
Enter dividend: 10
Enter divisor: 100
quotient: 0, remainder: 10

C Basic Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.