error: expected ‘while’ before ‘return’, Have equal amounts of closing and opening {}s and cant find the proble : <p>error: expected ‘while’ before ‘return’
return 0</p>

<p>I can't figure why it asks for a "while" before return</p>

<p>Tried nesting the code differently and can't find it work.</p>

<pre><code>int random;
    int userinput;
    random = rand() % 1000 + 1;

    do 
    {
    printf("Can you guess the random number? \n");
    scanf("%d", &amp;userinput);

        if (random &gt;= userinput)
        {   
            printf("The number you entered is too high! Try again! \n");
        }

        else if (random &lt;= userinput) 
        {
            printf("The number you entered is too low! Try again! \n");
        }

        while (random!=userinput)
        {
           printf("You guessed it! Correct! The number is: %d \n", random);
        }
    }
    return 0;
</code></pre>
