I am stuck on pset1 cash problem. When I run my script I get a blank and it never completes the calculation. The best I've been able to display is 0 even though its the wrong answer.
I figure I tackle getting the pennies portion right before making cookie-cutter formulas for the rest of the coins in the right order. In essence this is my proof of concept script.
Any or all input and advice is greatly appreciate it.
Thanks!
#include <cs50.h>
#include <stdio.h>
#include <math.h>
int main (void)
{
float n;
//do-while loop to prompt user until you get a positive dollar amount.
do
{
n = get_float("Enter the change you will give me: ");
}
while (n < 0);
//once you obtain a positive float round by multiplying by 100.
float x = round(n*100);
//convert your float to an integer
int c = x;
int pennies;
int r;
//while the amount of change is less than 5 cents
while ( c < 5)
;
{ //do modulo math to determine answer
pennies =c % 1
;
//subtract pennies from c to get the remainder
r = c - pennies;
//print how many pennies you are giving back.
printf("%i" , pennies);
}}
Also what on earth does "While loop has an empty body" mean ? why do I have to put the semicolon on the next line to fix it ?
Thanks.