-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProg60.c
More file actions
77 lines (71 loc) · 1.71 KB
/
Prog60.c
File metadata and controls
77 lines (71 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// C-program to count total number of notes in a given amount using if else.
#include <stdio.h>
int main()
{
int amount;
int note2000, note500, note200, note100, note50, note20, note10, note5, note2, note1;
note2000 = note500 = note200 = note100 = note50 = note20 = note10 = note5 = note2 = note1 = 0;
printf("Enter the amount: ");
scanf("%d", &amount);
if(amount >= 2000)
{
note500 = amount/2000;
amount -= note2000 * 2000;
}
if(amount >= 500)
{
note500 = amount/500;
amount -= note500 * 500;
}
if(amount >= 200)
{
note500 = amount/200;
amount -= note200 * 200;
}
if(amount >= 100)
{
note100 = amount/100;
amount -= note100 * 100;
}
if(amount >= 50)
{
note50 = amount/50;
amount -= note50 * 50;
}
if(amount >= 20)
{
note20 = amount/20;
amount -= note20 * 20;
}
if(amount >= 10)
{
note10 = amount/10;
amount -= note10 * 10;
}
if(amount >= 5)
{
note5 = amount/5;
amount -= note5 * 5;
}
if(amount >= 2)
{
note2 = amount /2;
amount -= note2 * 2;
}
if(amount >= 1)
{
note1 = amount;
}
printf("Total number of notes = \n");
printf("2000 = %d\n", note2000);
printf("500 = %d\n", note500);
printf("200 = %d\n", note200);
printf("100 = %d\n", note100);
printf("50 = %d\n", note50);
printf("20 = %d\n", note20);
printf("10 = %d\n", note10);
printf("5 = %d\n", note5);
printf("2 = %d\n", note2);
printf("1 = %d\n", note1);
return 0;
}