You are on page 1of 6

 Program for Display Hello World

using System;
namespace HelloWorldApplication
{
class HelloWorld
{
static void Main(string[] args)
{
/* my first program in C# */
Console.WriteLine("Hello World");
Console.ReadKey();
}
}
}

 Program for to calculate area of circle


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
double a, pi;
int r;
pi = 3.14;

Console.WriteLine(" Enter the Radius=");


r = int.Parse(Console.ReadLine());
a = pi * r * r;
Console.WriteLine(+a);
Console.ReadLine();
}
}
}
 Program for sum of digit

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace p1
{
class Program
{
static void Main()
{
int n, d, sum;
n = int.Parse(Console.ReadLine());
sum = 0;
while (n > 0)
{
d = n % 10;
sum = sum + d;
n = n / 10;

}
Console.WriteLine("sum=", +sum);
}
}
}

 Program for Swapping two number


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
int a, b, t;
a = int.Parse(Console.ReadLine());

b = int.Parse(Console.ReadLine());

t = a;
a = b;
b = t;
Console. WriteLine(+a);
Console.WriteLine(+b);
Console. ReadKey();
}
}
}

 Program for area and perimeter of rectangle


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication8
{
class Program
{
static void Main(string[] args)
{
int l, b, a, p;

Console.WriteLine(" Enter the values of l and b=");


l = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());

a = l * b;
p = 2 * (l + b);

Console.WriteLine(+a);
Console.WriteLine(+p);

Console.ReadLine();
}
}
}

 Program for sum and average of three number


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication9
{
class Program
{
static void Main(string[] args)
{
int a, b, c, sum;
double avg;

Console.WriteLine(" Enter the values of a,b,c:");


a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
c = int.Parse(Console.ReadLine());
sum = a + b + c;
avg = sum / 3;
Console.WriteLine(+sum);
Console.WriteLine(+avg);
Console.ReadLine();
}
}
}

 Program for Largest of two Number


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication10
{
class Program
{
static void Main(string[] args)
{
int a, b;
Console.WriteLine(" Enter the values of a,b:");
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
if (a > b)
Console.WriteLine(+a);
else
Console.WriteLine(+b);
Console.ReadLine();
}
}
}
 Program for Largest of three Number
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args)
{
int a, b,c;

Console.WriteLine(" Enter the values of a,b,c:");


a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
c = int.Parse(Console.ReadLine());

if (a > b && a > c)


Console.WriteLine("Ist no. is largest" + a);
else if (b > a && b > c)
Console.WriteLine("2nd no. is largest" + b);
else
Console.WriteLine(" 3rd no. is laregst" + c);

Console.ReadLine();
}
}
}
 Program for summation of two number
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace sum
{
class Program
{
static void Main(string[] args)
{
int a, b, c;
Console.WriteLine(" Enter the Nmu1:");
a = int.Parse(Console.ReadLine());
Console.WriteLine(" Enter the Num2:");
b = int.Parse(Console.ReadLine());
c = a + b;
Console.WriteLine(" Sum="+c);
Console.ReadLine();
}
}
}

You might also like