simple C# programs
Loading
simple C# programs
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sudarshan HajarePosted Jun 20, 2026, 12:38 AM
Here are simple c# programs
Hello World
using System;
class Program
{
static void Main()
{
Console.WriteLine("Hello, World!");
}
}
Add Two Numbers
using System;
class Program
{
static void Main()
{
int a = 10;
int b = 20;
int sum = a + b;
Console.WriteLine("Sum = " + sum);
}
}
Find Even or Odd Number
using System;
class Program
{
static void Main()
{
int num = 7;
if (num % 2 == 0)
Console.WriteLine("Even");
else
Console.WriteLine("Odd");
}
}
Swap Two Numbers
using System;
class Program
{
static void Main()
{
int a = 5, b = 10;
int temp = a;
a = b;
b = temp;
Console.WriteLine("a = " + a);
Console.WriteLine("b = " + b);
}
}
Find Largest of Three Numbers
using System;
class Program
{
static void Main()
{
int a = 10, b = 25, c = 15;
int largest = a;
if (b > largest)
largest = b;
if (c > largest)
largest = c;
Console.WriteLine("Largest = " + largest);
}
}