Answer the question repeatedly | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Answer the question repeatedly

Any sample codes for repeated question until he could answer it.

13th Feb 2020, 3:19 PM
Christine Samson
Christine Samson - avatar
4 Answers
+ 3
I don't understand. What do you wanna know ?
13th Feb 2020, 3:22 PM
Pedro H.J
Pedro H.J - avatar
+ 3
- enter loop - display question - take input - break from loop if correct If I understand correctly.
13th Feb 2020, 3:23 PM
Dennis
Dennis - avatar
+ 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
13th Feb 2020, 3:25 PM
Jax
Jax - avatar
+ 1
Try to search the Code Playground, "Guess the number" game usually implements such algorithm.
13th Feb 2020, 3:23 PM
Ipang