Q:

Write a C program to find quotient and remainder

0

C program to find quotient and remainder

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C programming Basic Input, Output, if else, Ternary Operator based Programs

Similar questions


need a help?


find thousands of online teachers now
Write a C program to calculate Simple Interest... >>
<< Write a C program to find cube of an integer numbe...