how to use a for loop to repeat a question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how to use a for loop to repeat a question

i want to use for loops to ask a question so the user will continue to input the name

13th Jun 2019, 5:06 PM
dave hazz
dave hazz - avatar
3 Answers
+ 4
where is your try???, finish the C# course and you will be able to do that
13th Jun 2019, 5:25 PM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 1
// for loop //your question in the for loop //??? //profit
13th Jun 2019, 5:32 PM
Jackson O’Donnell
+ 1
I would use a while loop? As soon as you don't want the code to repeat, just put in a false state and you're out of the loop. Boolean rotate= true; Console.WriteLine("rotate?"); while(rotate) { int x = Convert.ToInt32(Console.ReadLine()); if(x == 0) { rotate = false; } else { Console.WriteLine("try again"); rotate = true; // this is not needed } }
13th Jun 2019, 8:01 PM
HNNX 🐿
HNNX 🐿 - avatar