Skip to content

Instantly share code, notes, and snippets.

@moqdm
Last active September 6, 2021 13:25
Show Gist options
  • Select an option

  • Save moqdm/96755d08c21c1812f1cdde1b5a791f57 to your computer and use it in GitHub Desktop.

Select an option

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
#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