0
int calculate_quarters(int cents);
{
    // TODO
    int quarters;
    for(quarters = 0; cents >= quarters; quarters++)
    {
    cents = cents - 25;
    }
    return quarters;
}

The error happens at the second line at the first bracket. I have other functions for dimes, nickels, and pennies, but only the quarters seem to have an error. I don't think you can see it here, but in VS code there are 4 dots under the calculate_quarters function. That may have something to do with it. Thank you so much for the help!

1 Answer 1

0

Of course it does. ;-) When you create a function, the first line cannot end with a semicolon. That semicolon says to the compiler that "this is a signature line for a function that comes later on." A function signature that appears at the top of a program (the purpose of which is to tell the compiler that the actual function is coming later) must have a semicolon at the end. An actual function cannot have that semicolon because the code block that follows will be orphaned since the compiler can't tell that the code goes with the function declaration. The result is the error you're seeing.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

1
  • Thank you so much! I feel kinda silly now since there was such a simple solution.
    – Harr
    Commented Feb 10, 2023 at 21:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .