for and while Loops
for has init, condition and step. while and do while repeat on a condition.
Example
for (int i = 0; i < 3; i++) Console.Write(i + " ");
int n = 3;
while (n > 0) Console.Write(n-- + " ");
do { Console.Write("once"); } while (false);
Console.WriteLine();Exercise
Run once at least.
{ } while (c);Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.