Write a C program to input two numbers and print their quotient and remainder

 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",&dividend);
    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;
}
Output
Enter 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*/
}
 
Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment