Created
June 22, 2016 18:08
-
-
Save MuddyBootsCode/be50c9036dccb07556d92a14cb67cf91 to your computer and use it in GitHub Desktop.
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
#include<stdio.h> | |
#include<math.h> | |
#include<cs50.h> // only for CS50 IDE | |
int main (void) | |
{ | |
float change, rnd; | |
int quarters, dimes, nickles, pennies, coins; | |
do | |
{ | |
printf("How much change is owed?\n"); | |
rnd = GetFloat(); // scanf("%fl", &rnd); for non CS50 program | |
change = roundf(rnd*100); | |
} while (change <= 0 ); | |
quarters = (change / 25); | |
dimes = ((int)change % 25)/10; | |
nickles = (((int)change % 25) %10)/5; | |
pennies = ((((int)change % 25) %10) %5)/1; | |
coins = quarters + dimes + nickles + pennies; | |
printf("%d\n", coins); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment