C Program to Find Quotient and Remainder of Two Integers Entered by User | ZenTek ZenTek: C Program to Find Quotient and Remainder of Two Integers Entered by User
Contact Us:

If You Have Any Problem, Wanna Help, Wanna Write Guest Post, Find Any Error Or Want To Give Us Feedback, Just Feel Free To Contact Us. We Will Reply You Soon.

Name: *


Email: *

Message: *


ZenTek

LiveZilla Live Help

C Program to Find Quotient and Remainder of Two Integers Entered by User

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
Explanation

This program takes two integers(dividend and divisor) from user and stores it in variable dividend and divisor. Then, quotient and remainder is calculated and stored in variable quotient and remainder. Operator / is used for calculation of quotient and % is used for calculating remainder. Learn more about divison(/) and modulo division(%) operator in C programming
You can also program can be performed using only two variables as:

/* C Program to compute and display remainder and quotient  using only two variables */

#include <stdio.h>
int main(){
  int dividend, divisor;
  printf("Enter dividend: ");
  scanf("%d",&dividend);
  printf("Enter divisor: ");
  scanf("%d",&divisor);
  printf("Quotient = %d\n",dividend/divisor);/* Computes and displays quotient */
  printf("Remainder = %d",dividend%divisor); /* Computes and displays remainder */
  return 0;
}
Output of this program is same as program above but, only two variables are used in this case instead of four variables.


Like the Post? Share with your Friends:-

Team SB
Admin: Akash

0 comments:

POST A COMMENT

Contact Us

Name

Email *

Message *

 

About Me

Hello Guys

I am an IT(Information Technology) Student design this blog for your Preference I always enjoyed technical things as a kid

now here i am sharing my knowledge about Tips and Tricks In Internet PC Windows Free Recharges and Other Cool Stuffs Too

So enjoy it

Followers

Widget by : ZenTek
Widget by : ZenTek
Copyright © . ZenTek. All Rights Reserved.
Designed by :-Way2themes