Sunday, November 14, 2010

Display the Table of Input Number

class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter Table Number");
int a = Convert.ToInt32(Console.ReadLine());
int b = 0;
for (int i = 1; i <= 10; i++)
{
b = b + a;
Console.WriteLine(a+"*"+i+"="+b);
}

}
}

Display the Factor of a Number input by the user

class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter Any Number");
int a = Convert.ToInt32(Console.ReadLine());
int b=1;
for (; a >= 1; a--)
{
b = b * a;
}
Console.WriteLine(b);
}
}

Display the Factor of a Number

class Program
{
static void Main(string[] args)
{
int a=5,b=1;
for (; a >= 1; a--)
{
b = b * a;
}
Console.WriteLine(b);
}
}

Friday, November 12, 2010

To Check a Number is Even or Odd(Value Inserted by user)

class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter any Number");
int a = Convert.ToInt32( Console.ReadLine());
int b=a%2;
if (b==0)
{
Console.WriteLine("Number is Even");
}
else
{
Console.WriteLine("Number is Odd");
}
}
}

To Check a Number is Even or Odd

class Program
{
static void Main(string[] args)
{
int a = 4;
int b=a%2;
if (b==0)
{
Console.WriteLine("Even");
}
else
{
Console.WriteLine("Odd");
}
}
}

Thursday, November 11, 2010

Display 1 to 10 in different way

class Program
{
static void Main(string[] args)
{
int a = 1;
for (int i=0; i <10; i++)
{
Console.WriteLine(a);
a++;
}
}
}

Display 1 to 10

class Program
{
static void Main(string[] args)
{
for (int i=1; i <=10; i++)
{
Console.WriteLine(i);
}
}
}