[HELP] C++ while true loop
Go to solution
Solved by Nineshadow,
Your code has quite a few very obvious syntax issues.
Anyway :
#include <iostream> using namespace std; main() { int usersGuess; cout << "I'm thinking of a number between 1-100\n"; cout << "Guess what it is: "; cin >> usersGuess; while(true) { if( usersGuess == 7) break; if( usersGuess > 7 ) { cout << "That's too high.\n"; cout << "Guess what it is: "; cin >> usersGuess; } if( usersGuess < 7) { cout << "That's too low.\n"; cout << "Guess what it is: "; cin >> usersGuess; } } cout << "Jackpot!"; }
This should fix it.
Learn the proper if statement syntax in C :
if(<condition>) { <instructions> }
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now