Count total number of notes in given amount
Sample Output
Count total number of notes in given amount. Enter your amount: 999 Note of 1000: 0 Note of 500: 1 Note of 100: 4 Note of 50: 1 Note of 20: 2 Note of 10: 0 Note of 5: 1 Note of 2: 2 Note of 1: 0 Process returned 13 (0xD) execution time : 3.449 s Press any key to continue.
Source Code
#include<stdio.h>
void main()
{
int amount, note1000, note500, note100, note50, note20, note10, note5, note2, note1;
printf("Count total number of notes in given amount.\n\n");
scanf("%d", &amount, printf("\nEnter your amount: "));
note1000 = amount / 1000;
amount = amount % 1000;
printf("Note of 1000: %d\n", note1000);
note500 = amount / 500;
amount = amount % 500;
printf("Note of 500: %d\n", note500);
note100 = amount / 100;
amount = amount % 100;
printf("Note of 100: %d\n", note100);
note50 = amount / 50;
amount = amount % 50;
printf("Note of 50: %d\n", note50);
note20 = amount / 20;
amount = amount % 20;
printf("Note of 20: %d\n", note20);
note10 = amount / 10;
amount = amount % 10;
printf("Note of 10: %d\n", note10);
note5 = amount / 5;
amount = amount % 5;
printf("Note of 5: %d\n", note5);
note2 = amount / 2;
printf("Note of 2: %d\n", note2);
note1 = amount % 2;
printf("Note of 1: %d\n", note1);
}
Sample Output
Count total number of notes in given amount. Enter your amount: 5693 Note of 1000: 5 Note of 500: 1 Note of 100: 1 Note of 50: 1 Note of 20: 2 Note of 10: 0 Note of 5: 0 Note of 2: 1 Note of 1: 1 Process returned 13 (0xD) execution time : 2.904 s Press any key to continue.
No comments:
Post a Comment