UNITED INSTITUE OF MANAGEMENT
(Faculty of Undergraduate Studies)
Naini, Prayagraj
Department of Computer Application
C# PROGRAMMING LAB
1. Write a program to take user input and display a greeting message.
2. Write a program that declares variables of different data types (int, float, double, bool,
char) and prints their values and the size (in bytes) of each type.
3. Implement a program to swap two numbers without using a third variable.
4. Create a program that takes a string input representing a number and converts it to an integer
and a double.
5. Write a program that takes three side lengths of a triangle as input and determines if the
triangle is equilateral, isosceles, or scalene.
6. Create a simple calculator using switch-case.
7. Write a program to check if a number is prime.
8. Create an integer and string array of size 5, initialize it with values, and print each element
along with its index.
9. Write a program that takes an array of integers and a target value as input. Search for the
target value in the array and print its index if found, otherwise print "Not found."
10. Write a program that takes 5 numbers as input from the user, stores them in an array, and
calculates the sum and average of the elements.
11. Write a program that takes an integer as input. Implement error handling to catch the
FormatException if the user enters non-numeric input.
12. Create an array and try to access an element beyond its bounds. Handle the
IndexOutOfRangeException and print an error message.
13. Create a custom exception class called NegativeNumberException. Write a program that
throws this exception if the user enters a negative number.