REPETITIVE STRUCTURES


        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Text;
        using System.Threading.Tasks;
        
        namespace ConsoleApp1
        {
            internal class Program
            {
                static void Main(string[] args)
                {
                    Console.WriteLine("Enter a number to draw the multiplication table: ");
                    int nMult = int.Parse(Console.ReadLine()); //Enter a number for multiplication
                    int n2 = 0; //The second number for multiplication is initialized to 0
        
        
                    //WHILE Structure
                    //Used when the end number of the loop is NOT known...
                    
        
                    //While (n2 = 0) is less than 12
                    while (n2 < 12)
                    {
                        //Execute the following code:
        
                        n2++; //n2 increases by 1 in each loop iteration... 1,2,3,4.... up to 12
        
                        ////We print the multiplication table: (nMult + " x" + n2)  //This part simply concatenates numbers to display them in order... They do NOT perform any operations...
                        Console.WriteLine(nMult + " X " + n2 + " = " + (n2 * nMult)); //Multiplication is performed only at the end... (n2 * nMult) is the result... 
                    }
        
        
                    //FOR Structure
        
                    //Used when the end number of the loop is known...
                    Console.WriteLine();
                    Console.WriteLine("Enter a number: ");
        
                    int number3 = int.Parse(Console.ReadLine());
        
                    Console.WriteLine();
        
                    //Numbers start from 0 --- example: 5 will go through the following positions [0,1,2,3,4].
                    for (int i = 0; i < number3; i++)
                    {
        
                        //Various calculations can be performed within the for loop
                        Console.WriteLine(i);
                        // 0
                        // 1
                        // 2
                        // ...
                    }
        
                    //DO WHILE Structure
                    //Used to execute the code before the loop starts.
                    int option = 0;
                    do
                    {
                        Console.WriteLine("Enter a number greater than 5 to exit the loop...");
                        option = int.Parse(Console.ReadLine());
        
                    } while (option < 5); //While the option is less than 5...
                                          //Stay in the loop...
                                          //But if it is greater, exit the loop...
        
        
                    ////It is important that the program does not close automatically...
                    Console.ReadKey(); //This key keeps the program open... important to use when working with loops...
                }
            }
        }