C# Assignments
C# Assignments
1. Basic Calculator
Example:
Result: 10 * 5 = 50
Example:
Enter a number: 7
7 is an Odd number.
Enter a number: 12
12 is an Even number.
Enter a number: 0
Factorial of 0 = 1
Example:
Enter the number of terms: 7
Fibonacci Series: 0 1 1 2 3 5 8
5. Reverse a Number
Example:
Enter a number: 12345
Reversed Number: 54321
Example:
Enter a string: Hello World
Vowels: 3
Consonants: 7
Example:
Enter the number of elements: 5
Enter elements: 12 45 2 67 34
Largest: 67
Smallest: 2
Sum of matrices:
6 8
10 12
Multiplication result:
19 22
43 50
Example:
Enter text to write in file: Hello, this is a test file!
Text written successfully.
Example:
Enter number of students: 2
Student Details:
-----------------
Name: John, Roll No: 101, Total: 253, Average: 84.33
Name: Alice, Roll No: 102, Total: 259, Average: 86.33
Example:
Enter a string or number: madam
Palindrome: YES
Example:
Enter number of elements: 5
Enter elements: 1 2 3 4 5
Reversed Array: 5 4 3 2 1
Example:
Enter number of students: 2
Enter details for Student 1:
Name: John
Roll Number: 101
Marks: 85 90 78
Student Details:
-----------------
Name: John, Roll No: 101, Marks: 85 90 78
Name: Alice, Roll No: 102, Marks: 88 76 95
Example:
Enter operation (push, pop, peek, isEmpty, exit): push
Enter value: 10
Stack updated.
Example:
Enter infix expression: A + B * C
Postfix expression: A B C * +
Example:
Enter operation (insert_begin, insert_end, delete, reverse, display,
exit): insert_begin
Enter value: 10
Linked list updated.
Example:
Enter operation (insert, delete, search, inorder, preorder,
postorder, exit): insert
Enter value: 50
BST updated.
Example:
Welcome to Bank Management System!
Choose an option:
1. Create Account
2. Deposit Money
3. Withdraw Money
4. Check Balance
5. Exit
Enter choice: 1
Enter Name: John
Enter Initial Deposit: 5000
Account Created Successfully!
Enter choice: 2
Enter Amount to Deposit: 2000
Deposit Successful. New Balance: 7000
Enter choice: 3
Enter Amount to Withdraw: 1500
Withdrawal Successful. New Balance: 5500
Enter choice: 4
Your Account Balance: 5500
Enter choice: 5
Thank you for using the system!
Example:
Enter number of vertices: 5
Enter number of edges: 6
Example:
Enter number of vertices: 4
Enter number of edges: 5
Example:
Enter operation (enqueue, dequeue, display, exit): enqueue
Enter value: 10
Queue updated.
Example:
Enter number of elements: 5
Enter elements: 40 10 30 50 20
Example:
Enter words to insert: apple, ape, bat, ball, cat
26. Implement a LRU (Least Recently Used) Cache using Doubly Linked List
Example:
Enter cache size: 3
Enter operations:
PUT (1,10)
Cache: [1 -> 10]
PUT (2,20)
Cache: [1 -> 10, 2 -> 20]
PUT (3,30)
Cache: [1 -> 10, 2 -> 20, 3 -> 30]
GET (2)
Cache: [1 -> 10, 3 -> 30, 2 -> 20] (2 moved to most recently used)
PUT (4,40)
Cache: [3 -> 30, 2 -> 20, 4 -> 40] (1 removed as LRU)
Example:
Enter postfix expression: 5 3 + 8 *
Result: (5 + 3) * 8 = 64
Example:
Enter number of vertices: 4
Enter number of edges: 5
Example:
Welcome to Flight Reservation System!
Enter choice:
1. Book Ticket
2. Cancel Ticket
3. View Booked Tickets
4. Exit
Enter choice: 1
Enter Passenger Name: John Doe
Enter Flight Number: AI202
Enter Seat Number: 15A
Booking Successful!
Enter choice: 3
Booked Tickets:
Passenger: John Doe, Flight: AI202, Seat: 15A
Enter choice: 2
Enter Flight Number: AI202
Enter Seat Number: 15A
Ticket Canceled!
Enter choice: 3
No Booked Tickets.
Example:
Input Sudoku:
5 3 _ | _ 7 _ | _ _ _
6 _ _ | 1 9 5 | _ _ _
_ 9 8 | _ _ _ | _ 6 _
---------------------
8 _ _ | _ 6 _ | _ _ 3
4 _ _ | 8 _ 3 | _ _ 1
7 _ _ | _ 2 _ | _ _ 6
---------------------
_ 6 _ | _ _ _ | 2 8 _
_ _ _ | 4 1 9 | _ _ 5
_ _ _ | _ 8 _ | _ 7 9
Solved Sudoku:
5 3 4 | 6 7 8 | 9 1 2
6 7 2 | 1 9 5 | 3 4 8
1 9 8 | 3 4 2 | 5 6 7
---------------------
8 5 9 | 7 6 1 | 4 2 3
4 2 6 | 8 5 3 | 7 9 1
7 1 3 | 9 2 4 | 8 5 6
---------------------
9 6 1 | 5 3 7 | 2 8 4
2 8 7 | 4 1 9 | 6 3 5
3 4 5 | 2 8 6 | 1 7 9