using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(“Please enter your target:”);
int UserTarget = int.Parse(Console.ReadLine());
int Start = 0;
while (Start <= UserTarget)
{
Console.Write(Start + ” “);
Start = Start + 2;
Console.ReadLine();
}
}
}
}
===============
DO WHILE LOOP
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(“Please enter your target:”);
int UserTarget = int.Parse(Console.ReadLine());
string UserChoice = ” “;
int Start = 0;
while (Start <= UserTarget)
{
Console.WriteLine(Start + ” “);
Start = Start + 2;
Console.ReadLine();
}
do
{
Console.WriteLine(“Do you want to continue – Yes or No”);
UserChoice = Console.ReadLine().ToUpper();
if (UserChoice != “Yes” && UserChoice != “No”)
{
Console.WriteLine(“Invalid Choice, Please say Yes or No”,UserChoice);
}
} while (UserChoice != “YES” && UserChoice != “NO”) ;
}while (UserChoice == “YES”);
}
}
========
FOR LOOP & FOREACH LOOP
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
for(int i = 0; i<= 20; i++)
{
if (i % 2 == 1)
continue;
Console.WriteLine(i);
Console.ReadLine();
}
//int[] EvenNumbers = new int[3];
//EvenNumbers[0] = 101;
//EvenNumbers[1] = 102;
//EvenNumbers[2] = 103;
//foreach(int i in EvenNumbers)
//{
// Console.WriteLine(i);
// Console.ReadLine();
//}
//for(int j = 0; j < EvenNumbers.Length; j++)
//{
// Console.WriteLine(EvenNumbers[j]);
// Console.ReadLine();
//}
//int i = 0;
//while (i < EvenNumbers.Length)
//{
// Console.WriteLine(EvenNumbers[i]);
// i++;
// Console.ReadLine();
//}
}
}
}