2 views
27 Jan 2026
Generate next lexicographic permutation.
Real Life: Finding all possible arrangements.
Step-by-Step Logic:
1. Sort array first
2. Use next_permutation() repeatedly
3. Generates next arrangement...
3 views
27 Jan 2026
Find position to insert element to keep sorted order.
Real Life: Finding where to place book in sorted shelf.
Step-by-Step Logic:
1. lower_bound() finds first position >= value
2. upper_bound() ...
3 views
27 Jan 2026
Add/remove from both front and back.
Real Life: Line where you can join from either end.
Step-by-Step Logic:
1. Create deque
2. push_front() adds to front
3. push_back() adds to back
4. pop_fr...
3 views
27 Jan 2026
Like set but allows duplicates, keeps sorted.
Real Life: Sorted list with repetitions allowed.
Step-by-Step Logic:
1. Create multiset
2. Insert elements (duplicates allowed)
3. Automatically so...
3 views
27 Jan 2026
Sort vector of pairs by second element.
Real Life: Sorting students by marks, not by name.
Step-by-Step Logic:
1. Create custom comparison function
2. Pass it to sort()
3. Define your own sorti...
4 views
27 Jan 2026
Store two related values as single unit.
Real Life: Storing coordinates (x,y), name-age pairs.
Step-by-Step Logic:
1. Create pair using make_pair()
2. Access first element using .first
3. Acces...
4 views
27 Jan 2026
Count how many times each element appears.
Real Life: Vote counting, inventory management.
Step-by-Step Logic:
1. Use map to store element and its count
2. For each element, increment its count
...
4 views
27 Jan 2026
Queue where highest priority element comes first.
Real Life: Emergency room - critical patients treated first.
Step-by-Step Logic:
1. Create priority_queue
2. Push elements
3. Top always gives ...
3 views
27 Jan 2026
Set automatically keeps only unique elements, sorted.
Real Life: Collection of unique items, no duplicates.
Step-by-Step Logic:
1. Create set
2. Insert elements
3. Duplicates automatically igno...
3 views
27 Jan 2026
Store data in key-value pairs like dictionary.
Real Life: Phone book - name (key) to number (value).
Step-by-Step Logic:
1. Create map
2. Insert key-value pairs
3. Access value using key
4. Ch...
4 views
27 Jan 2026
Search for element in vector using find().
Real Life: Searching for item in list.
Step-by-Step Logic:
1. Use find() function
2. It returns iterator
3. If found, iterator points to element
4. I...
3 views
27 Jan 2026
Sort vector in ascending and descending order.
Real Life: Arranging numbers in order automatically.
Step-by-Step Logic:
1. Create vector with unsorted elements
2. Use sort() function for ascendi...
2 views
27 Jan 2026
Use queue - First In First Out data structure.
Real Life: Like queue at ticket counter - first come first serve.
Step-by-Step Logic:
1. Create queue
2. Push adds to rear
3. Front shows first el...
2 views
27 Jan 2026
Use stack - Last In First Out data structure.
Real Life: Like stack of plates - take from top, put on top.
Step-by-Step Logic:
1. Create stack
2. Push elements (add to top)
3. Top shows element...
2 views
27 Jan 2026
Learn vector - dynamic array that can grow/shrink.
Real Life: Like a flexible list that auto-adjusts size.
Step-by-Step Logic:
1. Create vector
2. Add elements using push_back()
3. Access elem...
6 views
27 Jan 2026
Generate all possible arrangements of string characters.
Real Life: Password combinations, cryptography.
Step-by-Step Logic:
1. Fix one character
2. Generate permutations of remaining characters...
5 views
27 Jan 2026
Compress string by showing character and its count. "aaabbc" -> "a3b2c1"
Real Life: Data compression basics.
Step-by-Step Logic:
1. Count consecutive same characters
2. Write character and its c...
5 views
27 Jan 2026
Check if str2 is rotation of str1. Example: "abcd" -> "cdab".
Real Life: Circular string matching.
Step-by-Step Logic:
1. Check if lengths are equal
2. Concatenate str1 with itself
3. Check if...
4 views
27 Jan 2026
Remove all duplicate characters, keep only first occurrence.
Real Life: Unique character extraction.
Step-by-Step Logic:
1. Track which characters already seen
2. Add character to result only i...
7 views
27 Jan 2026
Find and print the longest word from a sentence.
Real Life: Text analysis, finding important words.
Step-by-Step Logic:
1. Extract each word
2. Compare length with previous longest
3. Update lo...
4 views
27 Jan 2026
Check if two strings have same characters but different order.
Real Life: "listen" and "silent" are anagrams.
Step-by-Step Logic:
1. Count frequency of each character in both strings
2. If all f...
4 views
27 Jan 2026
Check if one string exists inside another string.
Real Life: Search functionality in text.
Step-by-Step Logic:
1. For each position in main string
2. Check if substring matches from that positio...
5 views
27 Jan 2026
Check if one string exists inside another string.
Real Life: Search functionality in text.
Step-by-Step Logic:
1. For each position in main string
2. Check if substring matches from that positio...
5 views
27 Jan 2026
Count total number of words in a sentence.
Real Life: Word count in document editors.
Step-by-Step Logic:
1. Count spaces + 1 = number of words
2. Or count transitions from space to non-space
3...
5 views
27 Jan 2026
Delete all space characters from string.
Real Life: Cleaning up user input.
Step-by-Step Logic:
1. Create new string
2. Copy only non-space characters
3. Skip space characters
4. Return clean...
6 views
27 Jan 2026
Q6: Check Palindrome String
Problem: Check if string reads same forwards and backwards.
Real Life: Words like "madam", "radar", "level".
Step-by-Step Logic:
1. Compare first and last character...
4 views
27 Jan 2026
Check if two strings are exactly same or not.
Real Life: Like password verification.
Step-by-Step Logic:
1. Compare length first
2. If lengths different, strings not equal
3. Compare each chara...
4 views
27 Jan 2026
Reverse the order of characters in string.
Real Life: Like reading text backwards.
Step-by-Step Logic:
1. Use two pointers: start and end
2. Swap characters at start and end
3. Move start forwa...
7 views
27 Jan 2026
Reverse the order of characters in string.
Real Life: Like reading text backwards.
Step-by-Step Logic:
1. Use two pointers: start and end
2. Swap characters at start and end
3. Move start forwa...
4 views
27 Jan 2026
Count how many vowels (a,e,i,o,u) are in string.
Real Life: Analyzing text composition.
Step-by-Step Logic:
1. Check each character
2. If it matches a, e, i, o, u (any case)
3. Increment vowel ...
6 views
27 Jan 2026
Convert all lowercase letters to uppercase.
Real Life: Like CAPS LOCK on keyboard.
Step-by-Step Logic:
1. Check each character
2. If lowercase (a-z), convert to uppercase
3. Subtract 32 from AS...
5 views
27 Jan 2026
Count total characters in a string without using library function.
Real Life: Like counting letters in your name.
Step-by-Step Logic:
1. Start counter from 0
2. Loop through each character
3. S...
4 views
27 Jan 2026
Print letters in triangular pattern.
Real Life: Understanding character printing in patterns.
Step-by-Step Logic:
1. Start with 'A'
2. Each row prints consecutive letters
3. Number of letters =...
3 views
27 Jan 2026
Print diamond with only border.
Real Life: Combining hollow and diamond concepts.
Step-by-Step Logic:
1. Upper half: spaces, star, spaces, star
2. Lower half: mirror of upper
3. Only print star...
2 views
27 Jan 2026
Print numbers in zig-zag diagonal pattern.
Real Life: Understanding diagonal pattern logic.
Step-by-Step Logic:
1. Alternate between ascending and descending
2. Track current number
3. Print sp...
4 views
27 Jan 2026
Print Pascal's triangle with numbers.
Real Life: Important mathematical triangle in combinatorics.
Step-by-Step Logic:
1. Each row starts and ends with 1
2. Middle elements = sum of two above el...
2 views
27 Jan 2026
Print butterfly shape using stars.
Real Life: Complex symmetric pattern.
Step-by-Step Logic:
1. Upper half: stars on sides, spaces in middle
2. Lower half: mirror of upper half
3. Calculate sta...
2 views
27 Jan 2026
Print numbers in triangular form (1, 2 3, 4 5 6...).
Real Life: Famous number pattern in mathematics.
Step-by-Step Logic:
1. Start counter from 1
2. Each row has row_number elements
3. Print an...
3 views
27 Jan 2026
Print square with only border stars.
Real Life: Understanding boundary detection.
Step-by-Step Logic:
1. Print star if first or last row
2. Print star if first or last column
3. Otherwise print...
4 views
27 Jan 2026
Print complete diamond shape.
Real Life: Combining pyramid and inverted pyramid.
Step-by-Step Logic:
1. First print upper pyramid (n rows)
2. Then print lower inverted pyramid (n-1 rows)
3. Com...
3 views
27 Jan 2026
Print upside-down pyramid.
Real Life: Reverse of regular pyramid.
Step-by-Step Logic:
1. Spaces increase each row
2. Stars decrease each row
3. Spaces = current row - 1
4. Stars = 2*(n-row+1) ...
3 views
27 Jan 2026
Print centered pyramid of stars.
Real Life: Classic pyramid shape.
Step-by-Step Logic:
1. Print spaces first for centering
2. Spaces = n - current row
3. Then print stars = 2*row - 1
4. Create...
2 views
27 Jan 2026
Print numbers in sequential order (1,2,3...).
Real Life: Continuous counting in pattern.
Step-by-Step Logic:
1. Keep a counter starting from 1
2. Print counter value
3. Increment counter after ...
4 views
27 Jan 2026
Print numbers instead of stars in pattern.
Real Life: Understanding value printing in patterns.
Step-by-Step Logic:
1. Similar to triangle pattern
2. But print numbers instead of stars
3. Print...
4 views
27 Jan 2026
Print stars in decreasing pattern.
Real Life: Reverse of right triangle.
Step-by-Step Logic:
1. Row 1: print n stars
2. Row 2: print n-1 stars
3. Last row: print 1 star
4. Stars decrease each ...
2 views
27 Jan 2026
Print stars in increasing pattern (right triangle).
Real Life: Understanding row-dependent printing.
Step-by-Step Logic:
1. Row 1: print 1 star
2. Row 2: print 2 stars
3. Row n: print n stars
...
1 views
27 Jan 2026
Print a square pattern of stars.
Real Life: Basic pattern for learning nested loops.
Step-by-Step Logic:
1. Outer loop controls rows
2. Inner loop controls columns
3. Print star in each positio...
4 views
27 Jan 2026
Add two numbers using only bitwise operators.
Real Life: Understanding how CPU does addition internally.
Step-by-Step Logic:
1. XOR gives sum without carry
2. AND gives carry positions
3. Shift...
3 views
26 Jan 2026
Reverse the binary representation of a number.
Real Life: Used in network programming, cryptography.
Step-by-Step Logic:
1. Extract each bit from right
2. Add it to result from left
3. Shift or...
2 views
26 Jan 2026
All numbers appear twice except one. Find that single number.
Real Life: Finding unique item in paired data.
Step-by-Step Logic:
1. XOR of two same numbers is 0
2. XOR of any number with 0 is n...
4 views
26 Jan 2026
Check if number is power of 2 using single bitwise operation.
Real Life: Powers of 2 are special in computing (2, 4, 8, 16...).
Step-by-Step Logic:
1. Power of 2 has only one set bit (100, 1000, ...
3 views
26 Jan 2026
Count how many 1s are in binary representation of number.
Real Life: Used in computer architecture, compression.
Step-by-Step Logic:
1. Check last bit using & 1
2. If 1, increment counter
3. Ri...
3 views
26 Jan 2026
Swap two numbers using only XOR operator, no temp variable.
Real Life: Memory-efficient swapping technique.
Step-by-Step Logic:
1. a = a ^ b (combines both)
2. b = a ^ b (extracts original a)
3...
3 views
26 Jan 2026
Use bitwise AND with 1 to check even/odd instantly.
Real Life: Fastest way to check even/odd in programming.
Step-by-Step Logic:
1. Last bit of even numbers is 0
2. Last bit of odd numbers is 1
...
2 views
26 Jan 2026
Use ternary operator (? :) as shorthand if-else.
Real Life: Quick one-line decisions in code.
Step-by-Step Logic:
1. Syntax: condition ? value_if_true : value_if_false
2. Checks condition
3. Re...
4 views
26 Jan 2026
Shift bits left or right to multiply/divide by 2.
Real Life: Fast multiplication/division by powers of 2.
Step-by-Step Logic:
1. Left shift (...
3 views
26 Jan 2026
Perform bitwise operations on numbers.
Real Life: Used in low-level programming, flags, permissions.
Step-by-Step Logic:
1. AND (&): both bits must be 1
2. OR (|): at least one bit must be 1
3....
3 views
26 Jan 2026
Use compound assignment operators (+=, -=, *=, /=, %=).
Real Life: Like updating your bank balance, score etc.
Step-by-Step Logic:
1. Start with a value
2. Use +=, -=, *=, /=, %= for quick opera...
4 views
26 Jan 2026
Use logical operators to combine conditions.
Real Life: Like checking multiple conditions for decisions.
Step-by-Step Logic:
1. AND (&&): both must be true
2. OR (||): at least one must be true
...
2 views
26 Jan 2026
Compare two numbers using all comparison operators.
Real Life: Like comparing prices, ages, scores etc.
Step-by-Step Logic:
1. Take two numbers
2. Use ==, !=, >, =, ...
2 views
26 Jan 2026
Understand difference between ++x (pre) and x++ (post).
Real Life: Like counting up or down in different ways.
Step-by-Step Logic:
1. Pre-increment (++x): increases value first, then uses it
2. ...
3 views
26 Jan 2026
Perform all basic math operations on two numbers.
Real Life: Like using calculator for daily calculations.
Step-by-Step Logic:
1. Take two numbers
2. Apply +, -, *, /, % operators
3. Print all ...
4 views
26 Jan 2026
Count number of digits in a number using recursive function.
Real Life: Understanding number structure recursively.
Step-by-Step Logic:
1. Base case: if number is 0, return 0
2. Remove last digi...
5 views
26 Jan 2026
Move disks from one rod to another following rules.
Real Life: Classic recursion puzzle teaching problem-solving.
Step-by-Step Logic:
1. Move n-1 disks from source to auxiliary
2. Move largest d...
5 views
26 Jan 2026
Check if string reads same forwards and backwards using recursion.
Real Life: Words like "madam", "radar" that read same both ways.
Step-by-Step Logic:
1. Base case: if string empty or single cha...
5 views
26 Jan 2026
Generate nth Fibonacci number recursively.
Real Life: Understanding recursive patterns in nature.
Step-by-Step Logic:
1. Base case: if n is 0 return 0, if n is 1 return 1
2. Recursive case: retu...
6 views
26 Jan 2026
Calculate factorial using recursive function (5! = 5×4×3×2×1)
Real Life: Understanding how functions can call themselves.
Step-by-Step Logic:
1. Base case: if n is 0 or 1, return 1
2. Recurs...
7 views
26 Jan 2026
Create function with default parameter values.
Real Life: Like having default settings that can be changed if needed.
Step-by-Step Logic:
1. Give default value to parameters in declaration
2. If...
4 views
26 Jan 2026
Swap two variables using pass by reference.
Real Life: Like exchanging positions of two objects.
Step-by-Step Logic:
1. Use & in parameter to pass by reference
2. Changes in function affect orig...
5 views
26 Jan 2026
Pass array to function and find sum of all elements.
Real Life: Like sending list of items to calculate total bill.
Step-by-Step Logic:
1. Function receives array and its size
2. Loop through ar...
6 views
26 Jan 2026
Create multiple functions with same name for different shapes.
Real Life: Same "calculate area" action works for circle, rectangle etc.
Step-by-Step Logic:
1. Create calculateArea() for rectangle...
6 views
26 Jan 2026
Calculate x raised to power n (x^n) using recursive function.
Real Life: Like calculating compound interest repeatedly.
Step-by-Step Logic:
1. Base case: if power is 0, return 1
2. Recursive cas...
4 views
26 Jan 2026
Create function that prints a simple pattern of stars.
Real Life: Reusable code for printing designs.
Step-by-Step Logic:
1. Function takes number of rows as parameter
2. Use nested loops to pri...
5 views
26 Jan 2026
Function to calculate area of circle given radius.
Real Life: Like measuring area of circular garden.
Step-by-Step Logic:
1. Function takes radius as parameter
2. Use formula: Area = π × radiu...
4 views
26 Jan 2026
Create function that takes two numbers and returns larger one.
Real Life: Like choosing bigger apple from two apples.
Step-by-Step Logic:
1. Function receives two numbers
2. Compare both numbers
...
6 views
26 Jan 2026
Create function that checks if number is even or odd.
Real Life: Like categorizing numbers automatically.
Step-by-Step Logic:
1. Function takes one number as parameter
2. Check if number divides...
5 views
26 Jan 2026
Create function that takes two numbers and returns their sum.
Real Life: Like a adding machine that does addition for you.
Step-by-Step Logic:
1. Create function with two parameters
2. Add both ...
2 views
26 Jan 2026
Find all prime numbers between 1 and N efficiently.
Real Life: Used in cryptography and security.
Step-by-Step Logic:
1. Create array marking all numbers as prime initially
2. Start from 2 (firs...
2 views
26 Jan 2026
Convert decimal number to binary (base 2) representation.
Real Life: How computers store all data internally.
Step-by-Step Logic:
1. Take decimal number
2. Divide by 2 repeatedly
3. Store remai...
4 views
26 Jan 2026
Print diamond shape using stars.
Real Life: Making decorative patterns.
Step-by-Step Logic:
1. Divide into two parts: upper and lower
2. Upper part: spaces decrease, stars increase
3. Lower par...
4 views
26 Jan 2026
Number equals sum of cubes of its digits. Example: 153 = 1³+5³+3³
Real Life: Special numbers in mathematics.
Step-by-Step Logic:
1. Take original number and save it
2. Extract each digit one...
3 views
26 Jan 2026
Find largest number that divides both numbers completely.
Example: GCD of 12 and 18 is 6
Real Life: Used when simplifying fractions.
Step-by-Step Logic:
1. Take two numbers
2. Find smaller of t...
4 views
26 Jan 2026
Print series where each number is sum of previous two: 0,1,1,2,3,5,8...
Real Life: This pattern appears in nature like flower petals, pine cones.
Step-by-Step Logic:
1. Start with first two numbe...
2 views
26 Jan 2026
Check if number is prime (only divisible by 1 and itself).
Real Life: Like checking if you can divide chocolates equally in groups.
Step-by-Step Logic:
1. Take number to check
2. Try dividing by...
4 views
26 Jan 2026
Find factorial of N. Example: 5! = 5×4×3×2×1 = 120
Real Life: Used in probability and permutation calculations.
Step-by-Step Logic:
1. Take number N
2. Start result = 1
3. Multiply result w...
3 views
26 Jan 2026
Print multiplication table of any number (like 5 × 1 = 5, 5 × 2 = 10...)
Real Life: Like the multiplication tables you learn in school.
Step-by-Step Logic:
1. Take number for which you want tab...
3 views
26 Jan 2026
Check if given year is leap year or not.
Real Life: Like February having 29 days in some years.
Step-by-Step Logic:
1. Take year as input
2. Leap year if divisible by 4
3. But NOT leap if divisib...
2 views
26 Jan 2026
Make calculator that can add, subtract, multiply or divide.
Real Life: Like calculator on your phone.
Step-by-Step Logic:
1. Take two numbers
2. Take operation choice (+, -, *, /)
3. Use switch t...
5 views
26 Jan 2026
If N = 5, find sum 1+2+3+4+5 = 15
Real Life: Like adding page numbers from page 1 to page N.
Step-by-Step Logic:
1. Take value of N
2. Start sum = 0
3. Add numbers from 1 to N one by one
4. Prin...
3 views
26 Jan 2026
You have three numbers. Find which one is largest. Real Life: Like finding tallest person among three friends.
Step-by-Step Logic:
1. Take three numbers
2. First compare first two numbers
3. Then ...
2 views
26 Jan 2026
A student needs 40 marks to pass. Check if student passed or failed.
Step-by-Step Logic:
1. Take student's marks
2. Compare marks with passing marks (40)
3. If marks >= 40, student passed
4. O...
3 views
26 Jan 2026
Overload + operator to add two objects of user-defined class.
This teaches operator overloading concept.
Logic: Define special member function for operator
...
2 views
26 Jan 2026
Use friend function to access private members of a class from outside. This teaches special access privileges.
Logic: Friend function declared inside class but defined outside
...
2 views
26 Jan 2026
Create copy constructor to make deep copy of object. This teaches difference between shallow and deep copy.
Logic: Initialize new object using existing object's data...
4 views
26 Jan 2026
Use static member variable to count total objects created of a class. This teaches static member concept.
Logic: Static variable is shared by all objects
...
3 views
26 Jan 2026
Create class with private data members and public methods to access them. This teaches encapsulation principle.
Logic: Hide data, provide controlled access through methods
...
4 views
26 Jan 2026
Implement constructor overloading with default and parameterized
constructors. This teaches polymorphism basics.
Logic: Same function name but different parameters...
2 views
26 Jan 2026
Create a class with parameterized constructor to initialize objects at creation time. This teaches object initialization.
Logic: Constructor is called automatically when object is created
...
2 views
26 Jan 2026
Design a Student class with basic data members (name,age,rollno) and member functions to display details.
Logic: Use class to group related data and functions together
...
3 views
26 Jan 2026
Compare memory usage of union and struct with same members.This teaches memory optimization techniques.
Logic: Use sizeof to compare memory allocation
...
2 views
26 Jan 2026
Determine if system uses big-endian or little-endian byte order. This teaches memory layout concepts.
Logic: Store multi-byte value and check byte at pointer address
...
4 views
26 Jan 2026
Compare floating point numbers correctly considering precision errors. This teaches floating point arithmetic issues.
Logic: Check if absolute difference is less than small epsilon value...
4 views
26 Jan 2026
Implement decimal arithmetic using only integers by storing scaled values. This teaches number representation.
Logic: Multiply by 100 to store 2 decimal places as integers
...
7 views
23 Jan 2026
Add two integers while checking for overflow before it happens. This teaches defensive programming.
Logic: Check if addition exceeds INT_MAX before performing
...
4 views
23 Jan 2026
Display binary representation of different data types. This builds understanding of how data is stored in memory.
Logic: Extract and display individual bits using bitwise operations...
6 views
23 Jan 2026
Show memory consumption of arrays with different data types. This teaches memory optimization.
Logic: Calculate array size = elements × sizeof(type)
...
5 views
23 Jan 2026
Compare behavior of signed and unsigned integers, especially with negative values. This shows two's complement representation.
Logic: Assign negative value to unsigned and observe result
...
6 views
23 Jan 2026
Demonstrate data loss when converting from larger to smaller data types. This teaches careful type selection.
Logic: Convert double to float to int and show precision loss
...
5 views
23 Jan 2026
Show what happens when you exceed maximum value of an integer. This teaches boundary conditions and wraparound behavior.
Logic: Add to maximum value and observe result...
5 views
23 Jan 2026
Convert temperature from Celsius to Fahrenheit and Kelvin using appropriate data types for decimal precision.
Logic: Apply conversion formulas using float/double
...
5 views
23 Jan 2026
Identify whether input character is a digit, alphabet, or special character. This uses ASCII value ranges.
Logic: Check ASCII value ranges for classification
...
6 views
23 Jan 2026
Calculate circle area using different precision levels (float vs double). This shows importance of choosing correct data type.
Logic: Perform same calculation with different types and compare...
7 views
23 Jan 2026
Convert values from one data type to another (implicit andexplicit). This teaches type conversion and data loss concepts.
Logic: Use cast operators to convert between types...
7 views
23 Jan 2026
Show the minimum and maximum values that different data types can store. This helps understand memory allocation and limits.
Logic: Use sizeof and limit constants to display ranges
...
10 views
23 Jan 2026
Arrange elements such that arr[0] >= arr[1] = arr[3]... This teaches pattern-based sorting and swapping logic.
Logic: Swap adjacent elements at odd positions if needed
...
5 views
23 Jan 2026
Find length of longest sequence of consecutive numbers that can be formed from array elements. This teaches set-based thinking.
Logic: For each number, check if it's start of sequence, then count l...
7 views
23 Jan 2026
Find three numbers in array whose sum equals target value.This develops nested loop optimization and multiple variable tracking.
Logic: Use three nested loops to check all possible combinations
...
7 views
23 Jan 2026
Shift all zero elements to the end while maintaining order of non-zero elements. This teaches two-pointer technique.
Logic: Use index to place non-zero elements, fill rest with zeros...
7 views
23 Jan 2026
Find index where sum of elements before it equals sum after it. This teaches prefix sum concept and optimization.
Logic: Calculate total sum, then track left sum while traversing
...
6 views
23 Jan 2026
Identify and display all prime numbers present in given array. This combines prime checking logic with array traversal.
Logic: For each number, check if it's prime using division method
...
7 views
23 Jan 2026
Rearrange array so all even numbers come before odd numbers. This teaches array partitioning logic.
Logic: Create two arrays for even/odd, then merge back...
6 views
23 Jan 2026
Count how many times each unique element appears in array. This develops nested loop logic and counting techniques.
Logic: For each element, count its occurrences in entire array
...
6 views
23 Jan 2026
Remove an element at a specific index and shift remaining
elements left. This teaches array manipulation and size management.
Logic: Shift all elements after deletion point one position left
...
6 views
23 Jan 2026
Write a program to insert a new element at a given position in
an array. This requires shifting elements to make space.
Logic: Shift elements right from insertion point, then insert new element...
5 views
23 Jan 2026
Search for a specific element and return its position (index). If not found, return -1. This teaches linear search concept.
Logic: Compare each element with search value
...
4 views
23 Jan 2026
Given an array with positive and negative numbers, count how many are positive and how many are negative. This builds conditional logic skills.
Logic: Check each number's sign and increment respectiv...
4 views
23 Jan 2026
Description: Write code to copy all elements from one array to another array. This demonstrates basic array manipulation and memory concepts.
Logic: Iterate through source array and assign to destina...
7 views
23 Jan 2026
Description: Create a program to find the smallest number in an array. This teaches comparison logic and how to track minimum values.
Logic: Assume first element is minimum, then compare with rest
...
8 views
23 Jan 2026
Write a program that takes an array of numbers and calculates their average. This helps understand array traversal and basic arithmetic operations.
Logic: Sum all elements and divide by total count...