Assignment’s C#
#Easy 1-10 Assignments
1. Basic Calculator
Example:
Enter first number: 10
Enter operator (+, -, *, /): *
Enter second number: 5
Result: 10 * 5 = 50
2. Even or Odd Number Checker
Example:
Enter a number: 7
7 is an Odd number.
Enter a number: 12
12 is an Even number.
3. Factorial of a Number (Using Recursion)
Example:
Enter a number: 5
Factorial of 5 = 120
Enter a number: 0
Factorial of 0 = 1
4. Fibonacci Series Generator
Example:
Enter the number of terms: 7
Fibonacci Series: 0 1 1 2 3 5 8
Enter the number of terms: 10
Fibonacci Series: 0 1 1 2 3 5 8 13 21 34
5. Reverse a Number
Example:
Enter a number: 12345
Reversed Number: 54321
Enter a number: 908
Reversed Number: 809
6. Count Vowels and Consonants in a String
Example:
Enter a string: Hello World
Vowels: 3
Consonants: 7
Enter a string: C Programming
Vowels: 4
Consonants: 8
7. Find Largest and Smallest Element in an Array
Example:
Enter the number of elements: 5
Enter elements: 12 45 2 67 34
Largest: 67
Smallest: 2
Enter the number of elements: 4
Enter elements: 98 23 77 4
Largest: 98
Smallest: 4
8. Matrix Addition and Multiplication
Example (Matrix Addition):
Enter first matrix (2x2):
1 2
3 4
Enter second matrix (2x2):
5 6
7 8
Sum of matrices:
6 8
10 12
Example (Matrix Multiplication):
Enter first matrix (2x2):
1 2
3 4
Enter second matrix (2x2):
5 6
7 8
Multiplication result:
19 22
43 50
9. File Handling: Write and Read a File
Example:
Enter text to write in file: Hello, this is a test file!
Text written successfully.
Reading from file...
File content: Hello, this is a test file!
10. Student Marks Management (Structure)
Example:
Enter number of students: 2
Enter details for Student 1:
Name: John
Roll Number: 101
Marks in 3 subjects: 85 90 78
Enter details for Student 2:
Name: Alice
Roll Number: 102
Marks in 3 subjects: 88 76 95
Student Details:
-----------------
Name: John, Roll No: 101, Total: 253, Average: 84.33
Name: Alice, Roll No: 102, Total: 259, Average: 86.33
#Medium 11-20 Assignments
11. Palindrome Checker (String & Number)
Example:
Enter a string or number: madam
Palindrome: YES
Enter a string or number: 121
Palindrome: YES
Enter a string or number: hello
Palindrome: NO
12. Sorting an Array using Bubble Sort and Quick Sort
Example (Bubble Sort):
Enter number of elements: 5
Enter elements: 34 12 5 78 45
Sorted Array using Bubble Sort: 5 12 34 45 78
Example (Quick Sort):
Enter number of elements: 6
Enter elements: 90 10 15 7 89 3
Sorted Array using Quick Sort: 3 7 10 15 89 90
13. String Manipulation without Built-in Functions
Example (String Length):
Enter a string: Hello
Length of string: 5
Example (String Concatenation):
Enter first string: Hello
Enter second string: World
Concatenated string: HelloWorld
Example (String Copy):
Enter a string to copy: OpenWorld
Copied string: OpenWorld
Example (String Comparison):
Enter first string: Hello
Enter second string: Hello
Strings are equal.
Enter first string: Hello
Enter second string: World
Strings are not equal.
14. Pointer-based Array Reversal
Example:
Enter number of elements: 5
Enter elements: 1 2 3 4 5
Reversed Array: 5 4 3 2 1
Enter number of elements: 6
Enter elements: 10 20 30 40 50 60
Reversed Array: 60 50 40 30 20 10
15. Dynamic Memory Allocation for a List of Students
Example:
Enter number of students: 2
Enter details for Student 1:
Name: John
Roll Number: 101
Marks: 85 90 78
Enter details for Student 2:
Name: Alice
Roll Number: 102
Marks: 88 76 95
Student Details:
-----------------
Name: John, Roll No: 101, Marks: 85 90 78
Name: Alice, Roll No: 102, Marks: 88 76 95
16. Stack Implementation using Arrays and Linked List
Example:
Enter operation (push, pop, peek, isEmpty, exit): push
Enter value: 10
Stack updated.
Enter operation: push
Enter value: 20
Stack updated.
Enter operation: peek
Top of stack: 20
Enter operation: pop
Popped value: 20
Enter operation: pop
Popped value: 10
Enter operation: isEmpty
Stack is empty.
17. Convert Infix Expression to Postfix
Example:
Enter infix expression: A + B * C
Postfix expression: A B C * +
Enter infix expression: (A + B) * (C - D)
Postfix expression: A B + C D - *
18. Linked List Operations
Example:
Enter operation (insert_begin, insert_end, delete, reverse, display,
exit): insert_begin
Enter value: 10
Linked list updated.
Enter operation: insert_end
Enter value: 20
Linked list updated.
Enter operation: insert_end
Enter value: 30
Linked list updated.
Enter operation: display
Linked List: 10 -> 20 -> 30
Enter operation: delete
Enter value to delete: 20
Linked List updated.
Enter operation: display
Linked List: 10 -> 30
Enter operation: reverse
Linked List reversed.
Enter operation: display
Linked List: 30 -> 10
19. Binary Search Tree (BST) Operations
Example:
Enter operation (insert, delete, search, inorder, preorder,
postorder, exit): insert
Enter value: 50
BST updated.
Enter operation: insert
Enter value: 30
BST updated.
Enter operation: insert
Enter value: 70
BST updated.
Enter operation: inorder
Inorder Traversal: 30 50 70
Enter operation: search
Enter value: 30
Found in BST.
Enter operation: delete
Enter value: 30
Deleted from BST.
Enter operation: inorder
Inorder Traversal: 50 70
20. Bank Account Management System (Mini Project)
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!
#Hard 21-30 Assignments
21. Implement a Graph using Adjacency List and Perform BFS & DFS Traversal
Example:
Enter number of vertices: 5
Enter number of edges: 6
Enter edges (source -> destination):
1 -> 2
1 -> 3
2 -> 4
2 -> 5
3 -> 5
4 -> 5
Adjacency List Representation:
1 -> 2 -> 3
2 -> 1 -> 4 -> 5
3 -> 1 -> 5
4 -> 2 -> 5
5 -> 2 -> 3 -> 4
BFS Traversal (starting from node 1): 1 2 3 4 5
DFS Traversal (starting from node 1): 1 2 4 5 3
22. Dijkstra’s Algorithm for Shortest Path in a Graph
Example:
Enter number of vertices: 4
Enter number of edges: 5
Enter edges with weight (source -> destination -> weight):
1 -> 2 -> 4
1 -> 3 -> 1
3 -> 2 -> 2
2 -> 4 -> 1
3 -> 4 -> 5
Enter source node: 1
Shortest Distance from Node 1:
To Node 2: 3
To Node 3: 1
To Node 4: 4
23. Implement a Circular Queue using Arrays
Example:
Enter operation (enqueue, dequeue, display, exit): enqueue
Enter value: 10
Queue updated.
Enter operation: enqueue
Enter value: 20
Queue updated.
Enter operation: enqueue
Enter value: 30
Queue updated.
Enter operation: display
Circular Queue: 10 20 30
Enter operation: dequeue
Dequeued value: 10
Enter operation: display
Circular Queue: 20 30
24. Implement a Min Heap and Perform Heap Sort
Example:
Enter number of elements: 5
Enter elements: 40 10 30 50 20
Min Heap Representation: 10 20 30 50 40
Sorted Array using Heap Sort: 10 20 30 40 50
25. Implement a Trie Data Structure for Searching Words
Example:
Enter words to insert: apple, ape, bat, ball, cat
Enter word to search: bat
Word found.
Enter word to search: ball
Word found.
Enter word to search: ban
Word not found.
Enter prefix to search: ba
Words with prefix 'ba': bat, ball
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)
27. Implement an Expression Evaluator for Postfix Expressions
Example:
Enter postfix expression: 5 3 + 8 *
Result: (5 + 3) * 8 = 64
Enter postfix expression: 10 2 8 * + 3 -
Result: (10 + (2 * 8)) - 3 = 23
28. Implement Kruskal’s Algorithm to Find Minimum Spanning Tree (MST)
Example:
Enter number of vertices: 4
Enter number of edges: 5
Enter edges with weights (source -> destination -> weight):
1 -> 2 -> 1
2 -> 3 -> 3
3 -> 4 -> 4
1 -> 4 -> 2
2 -> 4 -> 5
Minimum Spanning Tree (MST):
Edge 1 -> 2, Weight: 1
Edge 1 -> 4, Weight: 2
Edge 2 -> 3, Weight: 3
Total MST Weight: 6
29. Implement a Flight Reservation System (File Handling & Structures)
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.
30. Implement a Sudoku Solver using Backtracking
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