C++ program to read two numbers and print quotient and remainder.

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

Ans.

#include<iostream.h>

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

 

//Main Function

void main()

{

int dividend,divisor,remainder,quotient;

clrscr();  //for clear screen

 

cout<<“\n Enter the dividend: “;

cin>>dividend;

cout<<“\n Enter the divisor: “;

cin>>divisor;

 

quotient=dividend/divisor;

remainder=dividend%divisor;

 

cout<<“\n Quotient: “<<quotient;

cout<<“\n Remainder: “<<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 *

%d bloggers like this: