0

I want to create a simple program wherein the user inputs any number but only a postive integer is accepted (like the kind mentioned in the CS50 pset1 water walkthrough video) Ive been onto this for a while now but am nowhere near figuring out where ive gone wrong enter image description here

enter image description here

Is my format of the do while loop incorrect? what is the meaning of error: expected identifier or '('? Also, i thought int main(void) doesnt take a semicolon afterwards, why is it suggesting "expected ';' after top level declarator int main(void)" ?

4

The body of the main function must go between keys, the compiler interprets that as the keys are missing, declaring a function before main (this will be seen later) the solution is simple:

int main(void)
{
    int n;

    do
    {
      //code
    } 
     while...   
}
| improve this answer | |
  • I tried this and didn't work! Do you think you could repost with a new explanation? – Ruth Abebe May 9 at 20:33
  • The above answer should work. Check if you have named your function int Main(void), instead of int main(void). Having a capitalised M in main would produce the same error. – MoreCode May 10 at 9:41

You must log in to answer this question.

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