#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void)
{
{
float dollars;
// prompt user for "0.00" value
do
{
dollars = get_float("Change owed: ");
}
while(dollars <= 0);
}
// print amount of coins used for change
printf("%f\n", get_change(dollars));
int get_change(float dollars);
{
//calculate which coins will be used
int cents = round(dollars * 100);
int coins = 0;
int denom[] = {25, 10, 5, 1};
for (int i = 0; i < 4; i++);
{
coins += cents / denom[i];
cents = cents % denom[i];
}
return coins;
}
}
Doing Pset1 in CS50 and I'm completely lost as to why my code isn't working. Getting syntax error
cash.c:6:1: error: expected identifier or '('
You should remove
;
in this line:and here:
move
get_change
to first of file or use function declarations.It looks like you put one function inside another function. I don't have access to the header file, but I think what you need is more like the following.