Skip to content

Instantly share code, notes, and snippets.

@h3llborn
Created November 13, 2014 00:33
Show Gist options
  • Save h3llborn/f168e65ee0fe11e87692 to your computer and use it in GitHub Desktop.
Save h3llborn/f168e65ee0fe11e87692 to your computer and use it in GitHub Desktop.
create change for an amount
#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