Created
November 13, 2014 00:33
-
-
Save h3llborn/f168e65ee0fe11e87692 to your computer and use it in GitHub Desktop.
create change for an amount
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Author: Chris niesel | |
#include <stdio.h> | |
int main(void) { | |
int currency[] = {20,10,5,2,1}; | |
int amount = 59; | |
int num; | |
int i =0; | |
for(i;i<5;i++){ | |
if(currency[i]<=amount) | |
{ | |
num = amount / currency[i]; | |
printf("%dx $%d\n",num, currency[i]); | |
amount -=num*currency[i]; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment