## Jul 6, 2020

### C Program to print Total number of Notes in given Amount

Ex: Write a C program to find total number of notes in given amount. How to write a C program to print total number of notes in given amount. C program to print total number of notes in given amount.

Input from user:

Enter the amount: 2528

Expected output:

500=5

100=0
50=0
20=1
10=0
5=1
2=1
1=1

## Step by step logic of the given program:

1. First declare variables for each notes.

2. Accept input(amount) from user store it in variable say amount.

3. Use if-statement to check condition if amount is greater than or equal to 500(note value) then devide amount by 500 to get number of notes required. Store the result in varible note500:

note500=amount/500;

4.  After that, subtract the resultant amount of 500 notes from Original amount:

amount=amount-note500*500;

Also you can write this in short format:

amount -= note500*500;

5. Repeat about process for each note (100, 50, 20, 10, 5, 2 and 1) and print result on output screen.

# C program to print total number of notes in given amount:

#include<stdio.h>
void main()
{

int amount;

int note500,note100,note50,note20,note10,note5,note2,note1;

note500=note100=note50=note20=note10=note5=note2=note1=0;

printf("ENTER THE AMOUNT: ");
scanf("%d",&amount);

if(amount>=500)
{
note500=amount/500;
amount=amount-note500*500;
}
if(amount>=100)
{
note100=amount/100;
amount=amount-note100*100;
}
if(amount>=50)
{
note50=amount/50;
amount=amount-note50*50;
}
if(amount>=20)
{
note20=amount/20;
amount=amount-note20*20;
}
if(amount>=10)
{
note10=amount/10;
amount=amount-note10*10;
}
if(amount>=5)
{
note5=amount/5;
amount=amount-note5*5;
}
if(amount>=2)
{
note2=amount/2;
amount=amount-note2*2;
}
if(amount>=1)
{
note1=amount;

}

printf("TOTAL NUMBER OF NOTES:");
printf("\n500=%d",note500); printf("\n100=%d",note100);
printf("\n50=%d",note50); printf("\n20=%d",note20);
printf("\n10=%d",note10);
printf("\n5=%d",note5);
printf("\n2=%d",note2);
printf("\n1=%d",note1);

}

Above program shows the following output: