Code Sample | Loop Type | Explanation | for (int i = 1 ; i <11 ; i++){Console.WriteLine(“The counter is:” + i);}//program output//The counter is: 1//The counter is: 2//The counter is: 3//The counter is: 4//The counter is: 5//The counter is: 6//The counter is: 7//The counter is: 8//The counter is: 9//The counter is: 10 | for | The for loop loops through a block of code a number of times.This would be used for displaying a countdown timer or as a delay for an action. | int i = 1;while (i < 11){Console.WriteLine(“The counter is: ” + i);i++;}//program output//The counter is: 1//The counter is: 2//The counter is: 3//The counter is: 4//The counter is: 5//The counter is: 6//The counter is: 7//The counter is: 8//The counter is: 9//The counter is: 10 | while | While loops go through a block of code as long as another condition is true. This could be used to have a light turn on at night and off during the day. (While time < 20 {Light = off}) | do{//statement(s)}while (condition); | Do-while | IT does something while a condition is trueThis could be used to auto-update an application. | for (int i = 1; i <= 10; i++) //outer loop{System.out.println(“The multiplication table for: ” + i);for (j = 1; j <=10 ; j++) //inner loop loop{System.out.println(i + “ * ” + j + “ = ” + i*j);}}/* program outputThe multiplication table for: 11 * 1 = 11 * 2 = 21 * 3 = 3........1 * 10 = 10The multiplication table for: 22 * 1 = 12 * 2 = 42 * 3 = 6.........2 * 10 = 20The multiplication table for: 3..........The multiplication table for: 1010 * 1 = 1010 * 2 = 2010 * 3 = 30.........10 * 10 = 100*/ | nested | The inner loop is going when the outer loop is true.This could be used to display someone’s name and age. |