Write a program to print quotient and remainder.

 Q46. Write a program to read two numbers and print their quotient and remainder.

Ans.

#include<stdio.h>  //for standard input and output

#include<conio.h>  //for clrscr()

 

//Main Function

void main()

{

int dividend,divisor,remainder,quotient;

clrscr();  //for clear screen

 

printf(“\n Enter the dividend: “);

scanf(“%d”,&dividend);

printf(“\n Enter the divisor: “);

scanf(“%d”,&divisor);

 

quotient=dividend/divisor;

remainder=dividend%divisor;

 

printf(“\n Quotient: %d”,quotient);

printf(“\n Remainder: %d”,remainder);

 

getch();  //To hold the output screen

}

//End of main()

 

Output:

Enter the dividend: 20

Enter the divisor: 10

 

Quotient: 2

Remainder: 0

Leave a Reply

Your email address will not be published. Required fields are marked *

132 Views
%d bloggers like this: