Skip to content

Latest commit

 

History

547 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DSA Logic Building Problems in C++

Problem List

  1. Print a square of stars recursively (n×n). [link]
  2. Take marks (0–100) and print the corresponding grade (A/B/C/D/F). [link]
  3. Print numbers between 1–100 whose digits add up to a multiple of 3. [link]
  4. Create a new array containing only even elements. [link]
  5. Print Repeated Numbers per Row (Same Number Repeated) [link]
  6. Find the sum of even elements only. [link]
  7. Merge two arrays into one. [link]
  8. Replace all even numbers with 1 and odd numbers with 0 in array. [link]
  9. Find nCr (Combination formula) recursively using Pascal’s relation. [link]
  10. Print the alphabet incrementing in a left aligned pyramid pattern. [link]
  11. Find the frequency of each character in a string (without using a map). [link]
  12. Print Stars in Even Numbers (2, 4, 6, 8, 10) [link]
  13. Count how many times a number appears consecutively in an array. [link]
  14. Find element-wise sum of two arrays (A[i] + B[i]). [link]
  15. Remove consecutive duplicate characters (e.g., "aaabbcaaa" becomes "abca"). [link]
  16. Print the cube of numbers from 1 to n. [link]
  17. Check if a number is divisible by 5. [link]
  18. If the sides form a valid triangle, determine whether it is equilateral, isosceles, or scalene. [link]
  19. Find product of digits of a number recursively. [link]
  20. Print all factors of a given number. [link]
  21. Check if an array is sorted (ascending or descending). [link]
  22. Count the number of positive, negative, and zero elements in an array. [link]
  23. Print characters that appear more than once (without map). [link]
  24. Print all the odd numbers from 1 to 100. [link]
  25. Reverse an array in-place. [link]
  26. Take a 3-digit number and determine if the middle digit is the largest, smallest, or neither. [link]
  27. Count consonants and vowels separately using recursion. [link]
  28. Print Fibonacci series up to n terms. [link]
  29. Find the second largest element in an array. [link]
  30. Count how many positive, negative, and zero elements are in an array. [link]
  31. Print numbers between a and b divisible by 7. [link]
  32. Replace all vowels from a string with stars. [link]
  33. Count vowels in each word of a sentence. [link]
  34. Reverse a number recursively. [link]
  35. Print all the numbers from 1 to 100 whose sum is odd. [link]
  36. Check voting eligibility for a given age (18+). [link]
  37. Print pattern of numbers recursively (1 to n each row). [link]
  38. Rotate an array by one position to the left. [link]
  39. Check if a string is palindrome using recursion. [link]
  40. Print Increasing Numbers per Row (Same Number Repeated) starting from k. [link]
  41. Find the index of the minimum element. [link]
  42. Print the alphaBetic pyramid pattern starting from 'A' in the center of the pyramid without any space. The number of rows is given as input. [link]
  43. Take a 3-digit number and check if the sum of the first and last digit equals the middle digit. [link]
  44. Find the last occurrence of a given number in the array. [link]
  45. Print the count of the numbers between 1 and 500 that are divisible by 7 but not by 5. [link]
  46. Take a string input and print its length. [link]
  47. Check if a number is a strong number (sum of factorials of digits = number). [link]
  48. Check if the array is sorted in ascending order. [link]
  49. Print multiplication table of n recursively. [link]
  50. Count the number of digits in a number recursively. [link]
  51. Print sum of first n terms of Fibonacci series. [link]
  52. Print the product of digits of a given number. [link]
  53. Find LCM of two numbers using loops. [link]
  54. Find the maximum and minimum element in an array. [link]
  55. Take the hour of the day (0–23) and print “Good Morning”,“Good Afternoon”,“Good Evening”, or “Good Night”. [link]
  56. Print an Increasing Triangle of Stars [link]
  57. Replace every negative number with 0 in array. [link]
  58. Find the maximum element in an array. [link]
  59. Take a number and print “Fizz” if divisible by 3, “Buzz” if divisible by 5, and “FizzBuzz” if divisible by both. [link]
  60. Find sum of digits of a number recursively. [link]
  61. Monthnames [link]
  62. Calculate the sum of first n odd numbers recursively. [link]
  63. Take a character and check if it is a letter, a digit, or neither. [link]
  64. Print NxN star matrix. For example, if the number is 3 then print [link]
  65. Take a 3-digit number and check if all digits are distinct. [link]
  66. Print the numbers from 10 to 1 downward. [link]
  67. Shift all zeros to the end of the array. [link]
  68. Take three numbers and check if they can form a Pythagorean triplet. [link]
  69. Check if a number is both divisible by 3 and 5. [link]
  70. Find the sum of all elements except the largest and smallest. [link]
  71. Print the sum of first n natural numbers. [link]
  72. Find the shortest word in a sentence. [link]
  73. Print only odd numbers from 1 to N using recursion. [link]
  74. Take three numbers and print the largest number among three. [link]
  75. Print the reverse of a given number [link]
  76. Print the frequency of each distinct element. [link]
  77. Print all characters of a string one by one recursively. [link]
  78. Print all pairs in an array whose sum equals a given number. [link]
  79. Check if all elements in an array are unique. [link]
  80. Take coordinates (x, y) and check if the point lies on the X-axis, Y-axis, or at the origin. [link]
  81. Find GCD (HCF) of two numbers using Euclid’s algorithm recursively. [link]
  82. Find elements that are in one array but not in the other. [link]
  83. Take coordinates (x, y) and determine which quadrant the point lies in. [link]
  84. Print the even numbers from 1 to 100. [link]
  85. Print first n terms of an arithmetic progression (a, d). [link]
  86. Find the second largest element in an array. [link]
  87. Print pattern of characters (A, AB, ABC, ...) recursively. [link]
  88. Print a triangle of stars recursively (top-down). [link]
  89. Reverse the word of a sentence if the length of the word is even. [link]
  90. Print a multiplication table in a formatted grid (10x10). [link]
  91. Remove extra spaces between words (normalize spacing). [link]
  92. Find the index of the maximum element. [link]
  93. Sumoffirstnnaturalnumbersrecursively [link]
  94. Swap case: uppercase → lowercase and lowercase → uppercase. [link]
  95. Reverse the word of a sentence if the length of the word is even. (Another Approach) [link]
  96. Convert a string to uppercase recursively. [link]
  97. Reaplacealloccuranceofcharacter [link]
  98. Print a triangle of stars recursively (bottom-up). [link]
  99. Swap alternate elements (1st ↔ 2nd, 3rd ↔ 4th, etc.). [link]
  100. Print all unique elements from an array. [link]
  101. Take three numbers and check if they are in arithmetic progression. [link]
  102. Rotate an array by one position to the right. [link]
  103. Count how many elements are common between two arrays. [link]
  104. Print a pyramid pattern of numbers starting from '1' in all rows. The number of rows is given as input. [link]
  105. Take a single digit (0–9) and print its word form (“Zero” to “Nine”). [link]
  106. Check if a number is a perfect number. [link]
  107. Check if one of two given numbers is a multiple of the other. [link]
  108. Count how many times a given element appears. [link]
  109. Print the middle character(s) of a string. [link]
  110. Find the sum of odd elements only. [link]
  111. Print all Armstrong numbers between 1 and 1000. [link]
  112. Check if a number is even or odd. [link]
  113. Count how many elements are greater than the average of the array. [link]
  114. Print each word of a sentence on a new line. [link]
  115. Merge two arrays into a third array. [link]
  116. Print the numeric pyramid pattern starting from '1' and ending at '1' without a space. [link]
  117. Print all elements that appear more than once. [link]
  118. Take day and month and check if it forms a valid calendar date (ignoring leap years). [link]
  119. Print the Row wise alphabet incrementing in a left aligned pyramid pattern. [link]
  120. Count how many elements are even and odd. [link]
  121. Print all words that start and end with the same letter. [link]
  122. Take two numbers and print the larger one among two. [link]
  123. Print Fibonacci series up to n terms recursively. [link]
  124. Count how many vowels and consonants are in a string. [link]
  125. Find the HCF (GCD) of two numbers using loops. [link]
  126. Take 5 numbers as input. If the user enters 0, skip it using continue. At the end, print the sum of all non-zero numbers entered. [link]
  127. Take two strings and print them concatenated. [link]
  128. Print all the numbers from 1 to 100 whose sum is even. [link]
  129. Print the sum of all even numbers up to n using Arithmetic Progression. [link]
  130. Printcurrentcentury [link]
  131. Print digits of a number in words recursively (e.g., 123 → “one two three”). [link]
  132. Find the smallest and largest digit in a given number. [link]
  133. Check if a number is an Armstrong number. [link]
  134. Reverse a string without using built-in reverse. [link]
  135. Swap first and last words in a sentence. [link]
  136. Check if an amount can be evenly divided into 2000, 500, and 100 currency notes. [link]
  137. Print even numbers from 1 to N using recursion. [link]
  138. Count how many substrings start and end with the same character (simple logic). [link]
  139. Check if two strings are rotations of each other. [link]
  140. Rotate an array by one position to the right. [link]
  141. Print factorial of each number from 1 to n. [link]
  142. Take two numbers and determine whether both are even, both are odd, or one is even and one is odd. [link]
  143. Printfirstandlastcharacterofstring [link]
  144. Count how many words contain the letter 'a'. [link]
  145. Count how many elements are even at an even index. [link]
  146. Remove the first and last character and print the remaining string. [link]
  147. Print all the palindromes between 1 and 500 both inclusive. [link]
  148. Print a pattern where each row i prints i*i. [link]
  149. Count how many elements are perfect squares. [link]
  150. Print all prime numbers between 1 and 100. [link]
  151. Reverse the order of words in a sentence. [link]
  152. Check whether a string is a palindrome. [link]
  153. Keep only the first occurrence of each character. [link]
  154. Write a program to print the increasing and decreasing pattern of stars in each row. The number of rows is given as input. [link]
  155. Take a weekday number (1–7) and determine if it is a weekday or weekend. [link]
  156. Find the average of array elements. [link]
  157. Print the string in reverse order recursively (without using loops). [link]
  158. Take a character and check whether it’s uppercase, lowercase, a digit, or a special character. [link]
  159. Print the string after removing all digits. [link]
  160. Print 0 and 1 in a left aligned pyramid pattern. [link]
  161. Write a prrogram to print diamond pyramid of stars. n denote the length of upper triangle in diamond. [link]
  162. Type 2: Write a program to print the increasing and decreasing pattern of stars in each row. The number of rows is given as input. [link]
  163. Compare two strings lexicographically (like dictionary order). [link]
  164. Print Stars in Odd Numbers (1, 3, 5, 7, 9) [link]
  165. Print the alphaBetic pyramid pattern starting from 'A' in the center of the pyramid. The number of rows is given as input. [link]
  166. Reverse a string using recursion. [link]
  167. Take income and age, and check if eligible for tax (age > 18 and income > 5 L). [link]
  168. Print from N to 1 using recursion. [link]
  169. Print from 1 to N using recursion. [link]
  170. Check whether a given integer is single-digit, double-digit, or multi-digit. [link]
  171. Find the minimum element in an array. [link]
  172. Count the number of digits, letters, and special characters in a string. [link]
  173. Count vowels in a string recursively. [link]
  174. Count words that start and end with the same letter. [link]
  175. Print a pyramid pattern of alphabets starting from 'A' in all rows. The number of rows is given as input. [link]
  176. Find the sum of digits of a number. [link]
  177. Print first n terms of a geometric progression (a, r). [link]
  178. Remove duplicate characters from a string. [link]
  179. Find nth Fibonacci number recursively (index start with 1). [link]
  180. Check if two strings are the reverse of each other. [link]
  181. Print how many words start with a vowel in a sentence. [link]
  182. Take three numbers and check if they are in geometric progression. [link]
  183. Check if the given year is a leap year or not [link]
  184. Remove all spaces from a string. [link]
  185. Print a line of n stars recursively. [link]
  186. Reverse each word in a sentence. [link]
  187. Print the factorial of a given number. [link]
  188. Take two dates (day and month) and determine which one comes first in the calendar. [link]
  189. Reverse an array (without using built-in reverse). [link]
  190. Count how many pairs of elements have a sum equal to a given number k. [link]
  191. Find the second largest element in an array. [link]
  192. Find the count of prime numbers in the array. [link]
  193. Take three sides and check if they form a valid triangle. [link]
  194. Count how many words are in a sentence. [link]
  195. Convert all characters of a string to uppercase. [link]
  196. Find the first occurrence of a given number. [link]
  197. Print the sum of all odd numbers up to n. [link]
  198. Replace all spaces in a string with underscores. [link]
  199. Check if a number is a palindrome using recursion. [link]
  200. Remove duplicate words from a sentence. [link]
  201. Print the square of numbers from 1 to n. [link]
  202. Find the word with maximum vowels in a sentence. [link]
  203. Print the factorial of a given number N using Recursion. [link]
  204. Print the sum of all odd digits and even digits separately in a number. [link]
  205. Print numbers from 1 to 10. [link]
  206. Create a new array containing squares of all numbers. [link]
  207. Removealloccuranceofacharacterinastringusingrecursion [link]
  208. Find the common elements between two arrays. [link]
  209. Take an alphabet character and check if it lies between ‘a’ and ‘m’ or ‘n’ and ‘z’. [link]
  210. Print the sum of all even numbers up to n. [link]
  211. Take time (hours and minutes) and print the smaller angle between the hour and minute hands. [link]
  212. Print Numbers in an Increasing Sequence (1, 12, 123, 1234, 12345) [link]
  213. Create a frequency array of numbers (count occurrence of each number). [link]
  214. Count how many alphabets are before ‘m’ and after ‘m’ in a given string. [link]
  215. Count how many words have even length. [link]
  216. Compare two arrays — check if they contain the same elements (ignore order). [link]
  217. Check if two strings are anagrams (without using collections). [link]
  218. Check if a number lies within the range [100, 999]. [link]
  219. Print a Centered Pyramid of Stars [link]
  220. Print pattern of increasing characters (A, AB, ABC...). [link]
  221. Calculate power of a number (xⁿ) using recursion. [link]
  222. Convert all characters of a string to lowercase. [link]
  223. Print all unique elements (those that occur exactly once). [link]
  224. Copy one array to another manually. [link]
  225. Count how many characters (excluding spaces) are in the string. [link]
  226. Print pattern of numbers recursively (1 to n each row) forming a reverse triangle. [link]
  227. Print factorial of a number recursively. [link]
  228. Take n elements and print only those greater than a given value k. [link]
  229. Check if a number is prime or not. [link]
  230. Find element-wise product of two arrays (A[i] * B[i]). [link]
  231. Find the sum of digits of a number (use loop). [link]
  232. Toggle case for every alternate word in a sentence. [link]
  233. Find the sum of all elements at odd indices. [link]
  234. Take a character and check if it’s a vowel or consonant. [link]
  235. Shift each character by 1 (eg., "abc" becomes "bcd"). [link]
  236. Print all numbers between 1 and N that are divisible by both 3 and 5. [link]
  237. Convert a number to binary recursively. [link]
  238. Find nth Fibonacci number recursively (index start at 0). [link]
  239. Find the longest word in a sentence. [link]
  240. Check if a number is a multiple of 7 or ends with 7. [link]
  241. Take 24-hour time (hours and minutes) and print whether it is AM or PM. [link]
  242. Given a number print those many stars in a row. For example, if the number is 5 then print *****. [link]
  243. Swap the first and last elements of the array. [link]
  244. Count how many times a given character appears in a string. [link]
  245. Take a 4-digit number and check if the first and last digits are equal. [link]
  246. Input an element x — check if it exists in the array. [link]
  247. Reverse only characters, keeping digits in place. [link]
  248. Count how many uppercase and lowercase letters a string has. [link]
  249. Check if the number is palindrome. [link]
  250. Take two numbers and check if both are positive and their sum is less than 100. [link]
  251. Print the ASCII value of each character in a string. [link]
  252. Check whether the string is empty or not. [link]
  253. Print the table of a given number (n × 1 to n × 10). [link]
  254. Find the sum of all factors of a number. [link]
  255. Find the sum of all elements in an array. [link]
  256. Compare two arrays — check if they are equal (same elements & order). [link]
  257. Print Stars and Spaces Alternating (Stars and Blank Spaces replacing black space with 'b' character) [link]
  258. Print the second half of the string in reverse. [link]
  259. Check if a number is an Armstrong number or not. [link]
  260. Take a number (1-7) and print the corresponding day of the week. [link]
  261. Take a number and print whether it’s positive, negative, or zero. [link]
  262. Print all numbers from 1–n whose binary representation has an even number of 1s. [link]
  263. Capitalize the first letter of each word. [link]
  264. Remove all spaces from a string recursively. [link]
  265. Count the number of digits in a given number. [link]
  266. Print the sum of all odd numbers up to n using AP. [link]
  267. Reverse string but skip spaces. [link]
  268. Take a password string and check basic rules (length ≥ 8 and contains at least one uppercase letter, one lowercase letter, and one digit). [link]
  269. Take an integer (1–9999) and check if the sum of its digits is greater than the product of its digits. [link]
  270. Take electricity units consumed and calculate the bill as per slabs (using if-else). [link]
  271. Input n and take n integers into an array; print them. [link]
  272. Check if the array is sorted in descending order. [link]
  273. Print a Right-Aligned Triangle of Stars. [link]
  274. Count how many words end with ‘s’ [link]
  275. Count how many spaces are there in a sentence. [link]
  276. Print Increasing Numbers per Row (Same Number Repeated) starting from k and (0<=k<=9). [link]
  277. Take three numbers and print the median value (neither maximum nor minimum). [link]
  278. Remove all vowels from a string. [link]
  279. Find the second smallest element in an array. [link]
  280. Calculate the sum of first n even numbers recursively. [link]
  281. Check whether a number is a perfect square (without using the square root function). [link]
  282. Count how many numbers are divisible by 3 and 5 both. [link]
  283. Take two angles of a triangle and compute the third angle. [link]

About

A curated collection of data structures and algorithms problems focused on bridging the gap between coding syntax and problem-solving logic.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages