Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cs50.h>
- float f;
- int main(void){
- printf("Hi! How much change is owed?\n");
- f = get_float();
- while(f < 0){
- printf("Give me a positive number, bro!\n");
- f = get_float();
- }
- if(f == 0){
- printf("\nSo what the hell are you waiting for?\n");
- return 0;
- }
- int change = f * 100;
- int amount = change / 25;
- change %= 25;
- amount += change / 10;
- change %= 10;
- amount += change / 5;
- change %= rating;
- amount += change;
- printf("\n%i\n", amount);
- printf("Have a nice day!\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement