Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Home » Forum » x-Forum » Question

I am a beginner who has difficulties with the "do while" l

I am trying to program a "do while" loop that asks you a number from 1 to 8 until you answer a valid number. When I write it this way, it tells me that I am missing an expected identifier or '(' before the "do" and before the "while". When I try to add curly braces it still tells me the same message. The only way I found to escape this was to remove the part "int n;", but then the variable n isnt specified so it doesn't recognize it.

This is how I have written this:

int main(void);
int n;
do
{
    int n = get_int("Positive number: ");
} 
    while (n < 1 || n > 8);

Thank you in advance

Maxime Chayer-Lanthier

Posted by Maxime1009 2020-06-12 21:12:41

No Ans Posted

Please login to comment

Log In


Ask New Question