I am currently on PSET 1 Cash and have my program asking for the amount of change required, not accepting negative values and now I want to add a code block to start performing the operations on my float value f.
I need to declare this function at the top, before the int main(void) as done with the string prompt, however, I don't know the syntax. Any hints would be appreciated. The other issue is, I see some people write all their code in the int main(void) block, is this desirable?
float get_positive_float(string prompt);
float for(float f > i; ; f / i);
// prompts user for amount of cash
int main(void)
{
float f = get_positive_float("Change owed: ");
printf("%f\n", f);
}
// repeats prompt until cash >= 0
float get_positive_float(string prompt)
{
float f;
do
{
f = get_float("%s", prompt);
}
while (f < 1);
return f;
}
// divide change by coins iteratively until remainder is < .01
float for (float f > i; ; f / i)
{
for (float f > .25; ; f / .25);
{
printf("%f\n", f);
}
}