This C code shows how to find denominations of the entered amount. And code is helpful while user is in between any currency manipulation task.
code:
//Tested OK on Code::Blocks IDE 17.12 & Cygwin+GCC tools.
/* Program to find the number of 500, 100, 50, 20, 10, 5, 2, 1 -
RUPEES in entered amount.
*/
# include <stdio.h>
//# include <conio.h>
void main()
{
int rs, a, b, c, d, e, f, g, h ;
// clrscr() ;
printf("\nEnter the amount in Rupees : ") ;
scanf("%d", &rs) ;
while(rs >= 500)
{
a = rs / 500 ;
printf("\nThe no. of five hundreds are : %d", a) ;
break ;
}
while(rs >= 100)
{
b = rs / 100 ;
printf("\nThe no. of hundreds are : %d", b) ;
break ;
}
while(rs >= 50)
{
c = rs / 50 ;
printf("\nThe no. of fifties are : %d", c) ;
break ;
}
while(rs >= 20)
{
d = rs / 20 ;
printf("\nThe no. of twenties are : %d", d) ;
break ;
}
while(rs >= 10)
{
e = rs / 10 ;
printf("\nThe no. of tens are : %d", e) ;
break ;
}
while(rs >= 5)
{
f = rs / 5 ;
printf("\nThe no. of fives are : %d", f) ;
break ;
}
while(rs >= 2)
{
g = rs / 2 ;
printf("\nThe no. of Twos are : %d", g) ;
break ;
}
while(rs >= 1)
{
h = rs / 1 ;
printf("\nThe no. of ones are : %d \n\n", h) ;
break ;
}
getchar() ;
}
//end of program
To see such C code reviews refer blog archieve at right side or click CCode lable for till posted posts list.
...till next post, bye-bye and take care.
No comments:
Post a Comment