In this program, user is asked to enter two integers(dividend and
divisor) and this program will compute the quotient and remainder and
display it.
Source Code
/* C Program to compute remainder and quotient */
#include <stdio.h>
int main(){
int dividend, divisor, quotient, remainder;
printf("Enter dividend: ");
scanf("%d",÷nd);
printf("Enter divisor: ");
scanf("%d",&divisor);
quotient=dividend/divisor; /* Computes quotient */
remainder=dividend%divisor; /* Computes remainder */
printf("Quotient = %d\n",quotient);
printf("Remainder = %d",remainder);
return 0;
}
OutputEnter dividend: 25 Enter divisor: 4 Quotient = 6 Remainder = 1
Another Way
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
cout<<"Enter two numbers=";
cin>>a>>b;
cout<<"Quotient is:"<<a/b<<"\n";
cout<<"Remainder is:"<<a%b;
/*this program is simple one and it follows the
simple rules it doesn't check for the big and small number*/
}
0 comments:
Post a Comment