C# While and Do While
while repeats while a condition is true. do while runs the body at least once. break exits and continue skips to the next round.
Example
int n = 3;
while (n > 0) { Console.Write(n + " "); n--; }
Console.WriteLine();
int i = 0;
do { i++; } while (i < 3);
Console.WriteLine(i);Exercise
Run at least once.
{ } while (x);Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.