Logic Building Problems (150)
1. Find the sum of two numbers.
2. Find the difference between two numbers.
3. Find the product of two numbers.
4. Find the quotient of two numbers.
5. Find the remainder of a division.
6. Swap two numbers.
7. Check if a number is even or odd.
8. Check if a number is positive or negative.
9. Find the largest of two numbers.
10. Find the largest of three numbers.
11. Check if a number is divisible by 5.
12. Check if a number is divisible by 2 and 3.
13. Convert Celsius to Fahrenheit.
14. Convert Fahrenheit to Celsius.
15. Find the area of a rectangle.
16. Find the area of a circle.
17. Find the perimeter of a square.
18. Find the simple interest.
19. Find the compound interest.
20. Check if a year is a leap year.
21. Check if a character is a vowel or consonant.
22. Find the ASCII value of a character.
23. Calculate the square of a number.
24. Calculate the cube of a number.
25. Find the square root of a number.
26. Find the sum of first N natural numbers.
27. Find the sum of first N even numbers.
28. Find the sum of first N odd numbers.
29. Find the factorial of a number.
30. Generate multiplication table of a number.
31. Reverse a number.
32. Find the sum of digits of a number.
33. Check if a number is palindrome.
34. Check if a number is prime.
35. Find all prime numbers between 1 and N.
36. Find the greatest common divisor (GCD).
37. Find the least common multiple (LCM).
38. Check if a number is Armstrong.
39. Find all Armstrong numbers between 1 and N.
40. Check if a number is perfect number.
41. Print Fibonacci series up to N terms.
42. Find the Nth Fibonacci number.
43. Check if a string is palindrome.
44. Count the number of vowels in a string.
45. Count the number of words in a sentence.
46. Find the largest element in an array.
47. Find the smallest element in an array.
48. Find the sum of elements in an array.
49. Find the average of elements in an array.
50. Reverse an array.
51. Find duplicate elements in an array.
52. Sort an array in ascending order.
53. Sort an array in descending order.
54. Search for an element in an array.
55. Merge two arrays.
56. Find the second largest element in an array.
57. Find the second smallest element in an array.
58. Rotate an array by K positions.
59. Find the frequency of each element in an array.
60. Remove duplicate elements from an array.
61. Print a square pattern of stars.
62. Print a right triangle pattern of stars.
63. Print an inverted triangle pattern of stars.
64. Print a pyramid pattern of stars.
65. Print a diamond pattern of stars.
66. Print Floyd’s triangle.
67. Print Pascal’s triangle.
68. Print number pyramid.
69. Print an inverted number pyramid.
70. Print a checkerboard pattern.
71. Print multiplication triangle.
72. Print hollow square pattern.
73. Print hollow triangle pattern.
74. Print cross (X) pattern.
75. Print plus (+) pattern.
76. Reverse a string.
77. Find the length of a string.
78. Concatenate two strings.
79. Compare two strings.
80. Convert string to uppercase.
81. Convert string to lowercase.
82. Count frequency of each character in a string.
83. Find first non-repeating character in a string.
84. Find first repeating character in a string.
85. Remove vowels from a string.
86. Replace spaces with hyphens in a string.
87. Check if two strings are anagrams.
88. Find all substrings of a string.
89. Check if a substring exists in a string.
90. Remove duplicate characters from a string.
91. Find power of a number using loop.
92. Find power of a number using recursion.
93. Calculate sum of digits using recursion.
94. Find factorial using recursion.
95. Find GCD using recursion.
96. Find LCM using recursion.
97. Generate Fibonacci series using recursion.
98. Find maximum element in array using recursion.
99. Find minimum element in array using recursion.
100. Check if a number is prime using recursion.
101. Check palindrome string using recursion.
102. Find binary representation of a number.
103. Convert binary to decimal.
104. Convert decimal to binary.
105. Convert decimal to hexadecimal.
106. Find sum of diagonal elements in a matrix.
107. Find transpose of a matrix.
108. Add two matrices.
109. Subtract two matrices.
110. Multiply two matrices.
111. Find determinant of a matrix.
112. Check if a matrix is symmetric.
113. Find upper triangular matrix.
114. Find lower triangular matrix.
115. Find sum of each row of a matrix.
116. Find sum of each column of a matrix.
117. Check if a matrix is identity matrix.
118. Check if a matrix is sparse.
119. Search an element in matrix.
120. Print boundary elements of a matrix.
121. Implement linear search.
122. Implement binary search.
123. Implement bubble sort.
124. Implement selection sort.
125. Implement insertion sort.
126. Implement merge sort.
127. Implement quick sort.
128. Implement heap sort.
129. Find median of array.
130. Find mode of array.
131. Find mean of array.
132. Check if array is sorted.
133. Find missing number in array (1 to N).
134. Find duplicate number in array (1 to N).
135. Find majority element in array.
136. Solve Tower of Hanoi problem.
137. Solve N-Queens problem (N=4).
138. Find shortest path in a graph (Dijkstra).
139. Find minimum spanning tree (Prim’s).
140. Find minimum spanning tree (Kruskal’s).
141. Check if a graph is connected.
142. Check if a graph has a cycle.
143. Implement depth-first search (DFS).
144. Implement breadth-first search (BFS).
145. Find factorial using stack implementation.
146. Evaluate postfix expression.
147. Convert infix expression to postfix.
148. Implement queue using arrays.
149. Implement stack using arrays.
150. Check balanced parentheses using stack.