using System;
public class Program
{
public static void Main()
{
int i = 0;
while (i < 50)
{
Console.WriteLine("Value of i: {0}", i);
i++;
}
}
using System;
namespace Loop
class WhileLoop
public static void Main(string[] args)
int i=1, sum=0;
while (i<=5)
sum +=i;
i++;
Console.WriteLine("Sum={0}", sum);
using System;
public class Program
public static void Main()
for (int i=0; i<50; i++)
Console.WriteLine("Value of i:{0}", i);
using System;
public class Program
public static void Main()
for (double d = 1.01D; d < 1.10; d += 0.01D)
Console.WriteLine("Value of i:{0}", d);
using System;
public class Program
public static void Main()
{
for (int i = 0; i< 10; i++)
for (int j = i; j < 10; j++)
Console.WriteLine("Value of i:{0}, j: {1}", i, j);
using System;
public class Program
public static void Main()
int i= 0;
do
Console.WriteLine("Value of i:{0}", i);
i++;
while (i < 10);
using System;
namespace Loop
{
class DoWhileLoop
public static void Main(string[] args)
int i= 1, n = 5, product;
do
product = n * i;
Console.WriteLine("{0} * {1} = {2}", n, i, product);
i++;
while (i <= 10);
using System;
namespace Conditional
class IfStatement
public static void Main(string[] args)
int number = 2;
if (number < 5)
Console.WriteLine("{0} is less than 5", number);
}
Console.WriteLine("This statement is always executed.");
using System;
namespace Conditional
class IfStatement
public static void Main(string[] args)
int number = 8;
if (number < 5)
Console.WriteLine("{0} is less than 5", number);
else
Console.WriteLine("{0} is greater than or equal to 5", number);
Console.WriteLine("This statement is always executed.");
using System;
public class Exercise1
public static void Main()
{
int i;
Console.Write("Display the first 10 natural numbers:\n");
Console.WriteLine("The first 10 natural number are:");
for (i=1;i<=10;i++)
Console.Write("{0} ",i);
using System;
public class Numbers
public static void Main()
int i,n,sum=0;
double avg;
Console.Write("Input the 10 numbers : \n");
for (i=1;i<=10;i++)
Console.Write("Number-{0} :",i);
n= Convert.ToInt32(Console.ReadLine());
sum +=n;
avg=sum/10.0;
Console.Write("The sum of 10 no is : {0}The Average is : {1}\n",sum,avg);