0

error: expected identifier or '(' error: expected ';' after top level declarator int main (void)

code

#include <cs50.h> #include <stdio.h> #include <math.h>

int main(void) float dollar;

{ do { dollar=get_float("Enter your change here"); } while (dollar<=0);

int cents= round (dollar*100); int coins=0;

  while (cents>=25)

{ cents-=25; coins++; }

    while (cents>=10)

{ cents-=10; coins++; }

 while (cents>=5)

{ cents-=5; coins++; }

 while (cents>=1)

{ cents-=1; coins++; }

 printf ("You will need at least %i coins", coins);

}

1
  • cash.c:5:19: error: expected ';' after top level declarator int main (void) ^ ; cash.c:7:1: error: expected identifier or '(' { Nov 7 '20 at 16:26
1

I think your start should be like

int main (void)
{
    float dollar;

Not like

int main (void) float dollar;

Do this change and I think it should work.

1
  • Thank you I did that and it worked! Nov 7 '20 at 23:28
0

You need to add a semicolon (;) after each line

You must log in to answer this question.

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