Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gs-niteesh/674b52dc62512c7d66159b63095f987c to your computer and use it in GitHub Desktop.
Save gs-niteesh/674b52dc62512c7d66159b63095f987c to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(int argc, char const *argv[])
{
int n;
scanf("%d", &n);
int a=-1;
int b=-1;
int c=-1;
int d=-1;
int e=-1;
if(n >= 200){
a = n / 200;
n %= 200;
}
if(n >= 100){
b = n / 100;
n %= 100;
}
if(n >= 25){
c = n / 25;
n %= 25;
}
if(n >= 10){
d = n / 10;
n %= 10;
}
if(n >= 5){
e = n / 5;
n %= 5;
}
if(a != -1){
printf("%d toonies\n", a);
}else{
printf("0 toonies\n");
}
if(b != -1){
printf("%d loonies\n", b);
}else{
printf("0 loonies\n");
}
if(c != -1){
printf("%d quarters\n", c);
}else{
printf("0 quarters\n");
}
if(d != -1){
printf("%d dimes\n", d);
}else{
printf("0 dimes\n");
}
if(e != -1){
printf("%d nickels\n", e);
}else{
printf("0 nickels\n");
}
if (n != 0){
printf("%d pennies\n", n);
}else{
printf("0 pennies\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment