Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cs50.h>
- int main(void)
- {
- float change;
- float quarter = 0.25;
- float dime = 0.10;
- float nickel = 0.05;
- float penny = 0.01;
- int coinCount = 0;
- printf("Change: ");
- change = GetFloat();
- while (change >= quarter)
- {
- change -= quarter;
- coinCount ++;
- }
- while (change >= dime)
- {
- change -= dime;
- coinCount ++;
- }
- while (change >= nickel)
- {
- change -= nickel;
- coinCount ++;
- }
- while (change >= penny)
- {
- change -= penny;
- coinCount ++;
- }
- printf("%d\n", coinCount);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement