0
Answer the question repeatedly
Any sample codes for repeated question until he could answer it.
4 Respostas
+ 3
I don't understand. What do you wanna know ?
+ 3
- enter loop
- display question
- take input
- break from loop if correct
If I understand correctly.
+ 2
int answer = 5;
while(answer != 16){
cout << “Enter a number: “;
cin >> answer;
}
This bit of code will run until answer is equal to 16. It’s simple, but gets the job done
+ 1
Try to search the Code Playground, "Guess the number" game usually implements such algorithm.