Last active
September 6, 2021 13:25
-
-
Save moqdm/96755d08c21c1812f1cdde1b5a791f57 to your computer and use it in GitHub Desktop.
it's my PSet 1: Cash solution... *Please just take a look if you couldn't solve it ... Thank you π #cs50
This file contains hidden or 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 <cs50.h> | |
| #include <stdio.h> | |
| #include <math.h> | |
| int main(void) | |
| { | |
| int c = 0; | |
| //Get owe... | |
| printf("Write down the amount you owe to calculate the number of coins like ($.Β’)...\n"); | |
| float o; | |
| do | |
| { | |
| o = get_float("Owed: "); | |
| } | |
| while (0 > o); | |
| //rounding number. | |
| int ce = round(o * 100); | |
| //Quarter. | |
| while (25 <= ce) | |
| { | |
| ce = ce - 25; | |
| c++; | |
| } | |
| //Dime. | |
| while (10 <= ce) | |
| { | |
| ce = ce - 10; | |
| c++; | |
| } | |
| //Nickel. | |
| while (5 <= ce) | |
| { | |
| ce = ce - 5; | |
| c++; | |
| } | |
| //Penny. | |
| while (1 <= ce) | |
| { | |
| ce = ce - 1; | |
| c++; | |
| } | |
| //End! | |
| printf("%i\n", c); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment