Divide modulus operator program in c

// Calculate the number of rupees note of 2000, 500, 200, 100 in a given amount

#include<stdio.h>
#include<conio.h>
int main(){
int amount, tth, fh, th, h,x;
printf("Enter amount:");
scanf("%d",&amount);

x=amount;

tth=amount/2000;
amount=amount%2000;

fh=amount/500;
amount=amount%500;

th=amount/200;
amount=amount%200;

h=amount/100;

printf("Amount=%d \n",x);
printf("2000 notes=%d \n",tth);
printf("500 notes=%d \n",fh);
printf("200 notes=%d \n",th);
printf("100 notes=%d \n",h);
}

Output:
Enter amount: 19900
2000 notes=9
500 notes=3
200 notes=2
100 notes=0


In this program, we are learning about how to use divide and modulus arithmetic operators in the c program.

Divide operator (/): This operator divide number and return the quotient.

The modulus operator (%): This operator divides the number and returns the remainder.

Post written by: Hemant Singh
© 2020 - 2020 All rights are reserved