0% found this document useful (0 votes)
4 views1 page

Unit 2 Program

The document outlines a C# programming lab for undergraduate students at the United Institute of Management. It includes a series of programming tasks such as creating greeting messages, variable declarations, number swapping, triangle type determination, and implementing error handling. Additionally, it covers array manipulation, searching for values, and custom exception handling.

Uploaded by

avanishgoswami9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Unit 2 Program

The document outlines a C# programming lab for undergraduate students at the United Institute of Management. It includes a series of programming tasks such as creating greeting messages, variable declarations, number swapping, triangle type determination, and implementing error handling. Additionally, it covers array manipulation, searching for values, and custom exception handling.

Uploaded by

avanishgoswami9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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.

You might also like