Posts

Showing posts from March, 2021

Looping notes

There are four different types of loop in programing The for loop is used to count from one value to another. The for each loop is used to easily iterate over all of the elements in a collection. The while loop is used to go on as long as some condition is true. The do while loop is used to always execute at least once. Example of a for loop will look like For (int i=; i++) Console.Write (i ” “); } Example of a for each loop will look like Int [ ] values = 0,1,2,3,4}; Foreach (int value in values) { Console.Write (value +” “) { Example of while loop will look like Int i =0; While (i>5) } Console.Write (it” “); I++; } Example of do while loop will look like Int i=0; Do { Console.Write (it” “); I++; } while (i<5;)