C PROGRAM
Program for currency denomination |C Program|
Introduction
Understanding the intricacies of handling currency denominations is crucial in various programming scenarios. In this blog post, we delve into a simple C program that calculates the breakdown of currency notes for a given amount. The code provides insight into the logic behind counting the number of notes for different denominations.
Code
// Program for currency denomination
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10]={2000,500,100,50,20,10,5,2,1};
int i,m,temp;
clrscr();
printf("enter the amount:");
scanf("%d",&m);
temp=m;
for(i=0;i<9;i++)
{
printf("\n%d notes is:%d",a[i],temp/a[i]);
temp=temp%a[i];
}
getch();
}
Output
// Output
enter the amount:2135
2000 notes is:1
500 notes is:0
100 notes is:1
50 notes is:0
20 notes is:1
10 notes is:1
5 notes is:1
2 notes is:0
1 notes is:0
Explanation
1. Header Files:
The program includes the header for standard input/output and for console input/output. Note that is not part of the standard C library and might not be available on all compilers.
Conclusion
This C program demonstrates a simple yet practical application of structures and conditional statements to convert time from the 24-hour format to the 12-hour format. Understanding such programs not only enhances programming skills but also provides insights into real-world applications where time representations vary based on conventions. The ability to manipulate time formats is essential in various programming scenarios, making this example valuable for learners and developers alike.
Post a Comment
0 Comments