using System;

namespace SwappingWithTemp

{

class Program

{

static void Main(string[] args)

{

int x = 10, y = 20;

int temp = x;

x = y;

y = temp;

Console.WriteLine("After swapping:");

Console.WriteLine("x = " + x);

Console.WriteLine("y = " + y);

Console.ReadLine();

}

}

}

✅ 2. Swap Two Numbers (Without Temp Variable)

OUTPUT

After swapping:

a = 10

b = 5

✅ 3. Reverse a String

using System;

namespace ReverseString

{

class Program

{

static void Main(string[] args)

{

string input = "hello";

char[] charArray = input.ToCharArray();

Array.Reverse(charArray);

string reversed = new string(charArray);

Console.WriteLine("Reversed string: " + reversed);

Console.ReadLine();

}

}

}

✅ 4. Check for Palindrome

using System;

namespace PalindromeCheck

{

class Program

{

static void Main(string[] args)

{

string input = "madam";

string reversed = new string(input.Reverse().ToArray());

if (input == reversed)

Console.WriteLine("Palindrome");

else

Console.WriteLine("Not Palindrome");

Console.ReadLine();

}

}

}

✅ 5. Fibonacci Series

using System;

namespace FibonacciSeries

{

class Program

{

static void Main(string[] args)

{

int n = 10, a = 0, b = 1;

Console.WriteLine("Fibonacci Series:");

for (int i = 0; i < n; i++)

{

Console.Write(a + " ");

int temp = a;

a = b;

b = temp + b;

}

Console.ReadLine();

}

}

}

✅ 6. Factorial of a Number

using System;

namespace FactorialProgram

{

class Program

{

static void Main(string[] args)

{

int num = 5, fact = 1;

for (int i = 1; i <= num; i++)

{

fact *= i;

}

Console.WriteLine("Factorial of " + num + " is: " + fact);

Console.ReadLine();

}

}

}

✅ 7. Prime Number Check

using System;

namespace PrimeCheck

{

class Program

{

static void Main(string[] args)

{

int num = 17, flag = 0;

for (int i = 2; i <= Math.Sqrt(num); i++)

{

if (num % i == 0)

{

flag = 1;

break;

}

}

if (flag == 0)

Console.WriteLine(num + " is Prime");

else

Console.WriteLine(num + " is Not Prime");

Console.ReadLine();

}

}

}

✅ 8. Sum of Digits

using System;

namespace SumOfDigits

{

class Program

{

static void Main(string[] args)

{

int num = 123, sum = 0;

while (num > 0)

{

sum += num % 10;

num /= 10;

}

Console.WriteLine("Sum of digits: " + sum);

Console.ReadLine();

}

}

}

✅ 9. Count Vowels in a String

using System;

namespace VowelCount

{

class Program

{

static void Main(string[] args)

{

string input = "interview";

int count = 0;

foreach (char c in input.ToLower())

{

if ("aeiou".Contains(c))

{

count++;

}

}

Console.WriteLine("Number of vowels: " + count);

Console.ReadLine();

}

}

}

✅ 10. Multiplication Table

using System;

namespace MultiplicationTable

{

class Program

{

static void Main(string[] args)

{

int num = 5;

Console.WriteLine("Multiplication Table of " + num + ":");

for (int i = 1; i <= 10; i++)

{

Console.WriteLine($"{num} x {i} = {num * i}");

}

Console.ReadLine();

}

}

}

✅ 1. Swap Two Numbers (Using Extra Variable)

OUTPUT

After swapping:

x = 20

y = 10

C# Programs for Interview

using System;

namespace SwappingWithoutTemp

{

class Program

{

static void Main(string[] args)

{

int a = 5, b = 10;

a = a + b;

b = a - b;

a = a - b;

Console.WriteLine("After swapping:");

Console.WriteLine("a = " + a);

Console.WriteLine("b = " + b);

Console.ReadLine();

}

}

}

OUTPUT

Reversed string: olleh

OUTPUT

Palindrome

OUTPUT

Fibonacci Series:

0 1 1 2 3 5 8 13 21 34

OUTPUT

Factorial of 5 is: 120

OUTPUT

17 is Prime

OUTPUT

Sum of digits: 6

OUTPUT

Number of vowels: 4

OUTPUT

Multiplication Table of 5:

5 x 1 = 5

5 x 2 = 10

5 x 3 = 15

5 x 4 = 20

5 x 5 = 25

5 x 6 = 30

5 x 7 = 35

5 x 8 = 40

5 x 9 = 45

5 x 10 = 50