I'm a pretty shitty programmer, I can barely slap together a helloworld anymore without a myriad of syntax errors. But hey, I got this one to work! For some reason, I got it in my head that integer division was the way to go with this. I wanted to use perl, just because I'm trying to learn it right now, but perl only does float division. So does JavaScript. So I had to pull out a couple C manuals.
#include
main()
{
int value;
int i;
int total=0;
int coins[5]={50,25,10,5,1};
printf("Enter an integer monetary value: \n");
scanf("%d", &value);
for(i=0; i<5; i++) {
total += value / coins[i];
value = value % coins[i];
}
printf("That's %d coins \n", total);
}
Pretty compact, I guess - the actual meat of the program is only 2 lines long. Keepin' it real - straight-up old skool K&R brace style.