Translate

Monday, April 20, 2020

Request the user for two integers and print their remainder after division

/*Print remainder after division*/



#include<stdio.h>
#include<conio.h>
 void main()
{
  int x, y, remain,div;
printf("Enter your first integer in x =");
scanf("%d",&x);
printf("Enter your second integer in y =");
scanf("%d",&y);
//division
div=x/y;
printf("division = %d",div);     
//modulus
remain=x%y;
printf("\nremainder after division = %d",remain);
getch();
}
Output:









Useful Notes:

  • Division: The ‘/’ divide operator divides the first operand by the second. For example, div=x/y. Here, dividend is divided by the divisor.
  • Modulus: The ‘%’  modulus operator returns the remainder when first operand is
  • divided by the second. The modulus "%" operator give us remainder  For example, remain=x%y.

Request the user for two integers and output them and their sum.

No comments:

Post a Comment

C program to make a calculator using the switch statement.

/*perform arithmetic calculation on integers in C language*/ #include<stdio.h> #include<conio.h> void main() {     char op;     ...