/*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.
No comments:
Post a Comment