It compiles without any problems, but when I try to execute it, the Terminal crashes. Do I get in some infinite loops here?
I would appreciate some help - thanks a lot!
#include <cs50.h>
#include <math.h>
#include <stdio.h>
int main(void)
{
// get user input
float cash;
do
{
cash = get_float("Please enter amount of dollars owed to you: ");
}
while (cash <= 0);
// round cents to nearest penny
int cents = round(cash * 100);
// find coins within amount of cents
int quarters;
while (cents >= 25)
{
quarters = cents % 25;
}
return 0;
int dimes;
while (cents >= 10)
{
dimes = cents % 10;
}
return 0;
int nickels;
while (cents >= 5)
{
nickels = cents % 5;
}
return 0;
int pennies;
while (cents > 0)
{
pennies = cents % 1;
}
return 0;
//print result amount of coins to screen
printf("%i\n", quarters + dimes + nickels + pennies);
}