0

I have been trying to follow the walk through for pset1 and I cannot get my code to work for the first part of water. It will not let me execute the do-while loop.

I have written the code just like it instructs you to do in the walk through. I must admit, I have looked up how other people have done this, just to try and learn from it, not just to copy it and progress, and they haven't even used d-while loops. Does this mean their code is "less efficient" and they would get lower marks? I really want to get this done using a do-while loop rather than how I've seen others do it.

In the walk through, she runs you through a few different codes, and it gets a bit confusing because this is one she tells you to use, however I can't get it working doing it the way she has said to do it. Pictured below!

https://i.stack.imgur.com/Qc0MM.png

Thanks!

1 Answer 1

1

You lack the main function, all console programs must have a main function:

int main(void)
{
    some code
}

The error is surely because the compiler thinks that you are going to define or declare a function, the do-while loop is the most appropriate for this case.

EDIT

All statements must end in semicolons (;)

int minutes = get_int()

should be:

int minutes = get_int();

Also the do-while loop should also end the same way:

do
{
    code...
}
while (minutes < 0);

However the main function should not have a semicolon:

int main(void)
{
    some code
}
3
  • That does make sense, and I have tried doing it. However I get the exact same two errors! I have tried this, and still get an error. imgur.com/a/tDD5a thoughts? Jan 23, 2017 at 22:21
  • I see that I had a syntax error on line ten (missing the ;) but I've added it in an it doesn't make a difference. Jan 23, 2017 at 22:23
  • You can read my edit
    – MARS
    Jan 23, 2017 at 23:17

You must log in to answer this question.

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