You have a couple of issues in this code that are mostly about structure.
First, the semicolon after the while condition serves as a statement terminator and basically means "While this condition is true, do nothing until it is false and then continue to the next line of code." In fact, if you entered a negative number, it should just sit there forever, looking like the computer is locked up.
Because of the semicolon, the curly brace pair serve only to define or delineate the next block of code. That block of code is going to get executed every time, no matter what value x has. (Well, sort of. In this code, if x < 1, it will never get past the infinite loop. If x >= 1, the print statement will execute once and the program continues to the end.)
If you remove the semicolon after the where condition, then the curly brace pair defines the code to be executed only when the test condition is true.
Second, (once you remove the semicolon) the way it is structured, your code will merely execute the print statement when x < 1, or not print anything when x >= 1. It won't go back and prompt for input again. It will just continue to the next statement in the program. You need to restructure the code to include the input request code inside the while loop. You also need to make sure that the loop executes at least once by using a do-while loop instead of just a while loop.
Here's a pseudocode example that might help you understand.
int main()
{
int x =0;
do
{
// prompt for and get input
// test for valid input
// if the input isn't right, print a comment to try again
// the while test will cause the code to repeat if input isn't right.
} while ( test for valid input ); // end of do-while loop.
}
If this answers your question, please accept the answer and mark the question as answered. Let's keep up on forum maintenance. ;-)
while ()
part