Q-22.Write a C program to input amount from user and print minimum number of notes (TK. 1000, 500, 100, 50, 20, 10, 5, 2, 1) required for the amount.

0
ব্যবহারকারীর কাছ থেকে পরিমাণ ইনপুট করতে এবং নোটের সর্বনিম্ন সংখ্যা মুদ্রণ করতে একটি সি প্রোগ্রাম লিখুন (TK। 1000, 500, 100,
50, 20, 10, 5, 2, 1) পরিমাণ জন্য প্রয়োজন।


Input
Input amount: 575
Output
Total number of notes: 
500: 1
100: 0
50: 1
20: 1
10: 0
5: 1
2: 0
1: 0

programming..................

  1. #include <stdio.h> int main() { int amount; int note500, note100, note50, note20, note10, note5, note2, note1; /* Initialize all notes to 0 */ note500 = note100 = note50 = note20 = note10 = note5 = note2 = note1 = 0; /* Input amount from user */ printf("Enter amount: "); scanf("%d", &amount); if(amount >= 500) { note500 = amount/500; amount -= note500 * 500; } 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; } /* Print required notes */ printf("Total number of notes = \n"); printf("500 = %d\n", note500); 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; }
ShoW



Post a Comment

0Comments
Post a Comment (0)