0% found this document useful (0 votes)
6 views

C++_Problems

C++ Problems
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

C++_Problems

C++ Problems
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Here is a list of 100 C++ coding problems ranging from easy to intermediate level.

Easy Problems

/Print "Hello, World!"


/Print a given integer
/Swap two numbers
/Check if a number is even or odd
/Find the largest of three numbers
/Sum of digits of a number
Reverse a number
/Find the factorial of a number
/Check if a number is prime
--Find the nth Fibonacci number
//Check if a string is a palindrome
//Find the length of a string
//Count the number of vowels in a string
//Reverse a string
//Find the largest element in an array
//Sum of all elements in an array
//Check if an array is sorted
//Find the second largest element in an array
//Remove duplicates from an array
//Find the common elements in two arrays
Find the GCD of two numbers
Find the LCM of two numbers
Convert a decimal number to binary
Convert a binary number to decimal
//Check if a year is a leap year
Calculate the power of a number
//Print all prime numbers up to a given number
// Find the sum of the first n natural numbers
//Print the multiplication table of a number
//Find the sum of all prime numbers up to a given number
//Check if a string is a valid palindrome
Count the frequency of each character in a string
//Find the maximum and minimum element in an array
Merge two sorted arrays
//Find the kth smallest element in an array
Rotate an array to the right by k positions
Find the sum of the elements in the main diagonal of a matrix
Transpose a matrix
Check if two strings are anagrams
Implement a stack using arrays
Implement a queue using arrays
Find the intersection of two arrays
Find the union of two arrays
Find the missing number in an array of size n-1 containing numbers from 1 to n
Find the duplicate number in an array
Find the longest common prefix among a set of strings
Implement a linked list and perform basic operations (insert, delete, display)
Implement a doubly linked list and perform basic operations (insert, delete,
display)
Reverse a linked list
Find the middle element of a linked list

Intermediate Problems

Implement a circular linked list and perform basic operations (insert, delete,
display)
Detect a cycle in a linked list
Find the intersection point of two linked lists
Implement a stack using linked list
Implement a queue using linked list
Convert an infix expression to postfix
Evaluate a postfix expression
Implement a binary search tree and perform basic operations (insert, delete,
search)
Find the height of a binary tree
Find the level order traversal of a binary tree
Find the inorder traversal of a binary tree without recursion
Find the preorder traversal of a binary tree without recursion
Find the postorder traversal of a binary tree without recursion
Find the diameter of a binary tree
Check if a binary tree is balanced
Find the lowest common ancestor of two nodes in a binary tree
Implement a heap and perform basic operations (insert, delete, heapify)
Find the k largest elements in an array
Implement a graph and perform basic operations (add edge, remove edge, display)
Perform a depth-first search (DFS) on a graph
Perform a breadth-first search (BFS) on a graph
Check if a graph is connected
Find the shortest path in a graph using Dijkstra's algorithm
Find the shortest path in a graph using Floyd-Warshall algorithm
Find the minimum spanning tree of a graph using Kruskal's algorithm
Find the minimum spanning tree of a graph using Prim's algorithm
Check if a graph contains a cycle
Find the strongly connected components of a graph
Implement the topological sort of a graph
Find the longest increasing subsequence in an array
Find the longest common subsequence of two strings
Find the edit distance between two strings
Find the maximum subarray sum using Kadane's algorithm
Find the longest palindromic substring in a string
Find the number of ways to make change for a given amount
Implement a trie and perform basic operations (insert, search, delete)
Find the number of islands in a 2D grid
Find the largest rectangle in a histogram
Find the maximum profit that can be made by buying and selling a stock
Find the maximum size subarray with a given sum
Implement a hash table and perform basic operations (insert, delete, search)
Find the maximum product subarray
Find the majority element in an array
Implement a priority queue using a heap
Find the minimum number of jumps to reach the end of an array
Find the longest substring without repeating characters
Find the number of unique paths in a grid
Solve the N-Queens problem
Solve the Sudoku puzzle
Find the maximum sum path in a binary tree

These problems should provide a good range of challenges from easy to intermediate
levels.
not use dsa questions use topics of array,function,pointers,dynamic memory
allocation,string,structure,file handling and more
ChatGPT

Sure, here is a list of 100 C++ coding problems that focus on topics like arrays,
functions, pointers, dynamic memory allocation, strings, structures, and file
handling, progressing from easy to intermediate:
Easy Problems
Arrays

Print elements of an array.


Find the sum of all elements in an array.
Find the largest element in an array.
Find the smallest element in an array.
Reverse an array.
Count occurrences of an element in an array.
Remove duplicates from an array.
Find the second largest element in an array.
Sort an array in ascending order.
Merge two sorted arrays.

Functions

Write a function to add two integers.


Write a function to check if a number is prime.
Write a function to calculate the factorial of a number.
Write a function to reverse a string.
Write a function to find the GCD of two numbers.
Write a function to find the LCM of two numbers.
Write a function to check if a number is even or odd.
Write a function to find the nth Fibonacci number.
Write a function to convert a decimal number to binary.
Write a function to find the length of a string.

Pointers

Print the address of a variable using pointers.


Swap two numbers using pointers.
Find the length of a string using pointers.
Reverse a string using pointers.
Sum of array elements using pointers.
Find the maximum element in an array using pointers.
Count vowels in a string using pointers.
Implement a function that uses pointer to pointer (double pointer).
Implement pointer arithmetic.
Implement dynamic array allocation and deallocation.

Dynamic Memory Allocation

Allocate memory for an integer using malloc/calloc.


Allocate memory for an array using malloc/calloc.
Reallocate memory using realloc.
Free dynamically allocated memory.
Create a dynamic 2D array.
Implement a simple memory leak and fix it.
Implement a program to demonstrate the use of new and delete.
Write a program to copy one array to another using dynamic memory.
Implement dynamic string allocation.
Write a program to dynamically allocate and deallocate a structure.

Intermediate Problems
Strings

Find the frequency of characters in a string.


Convert a string to uppercase.
Convert a string to lowercase.
Check if a string is a palindrome.
Implement string concatenation without using library functions.
Implement string comparison without using library functions.
Remove spaces from a string.
Find the first non-repeating character in a string.
Implement strstr function.
Find all substrings of a string.

Structures

Define a structure for a student with name, roll number, and marks.
Write a function to print the details of a student.
Write a function to find the student with the highest marks.
Implement an array of structures.
Write a function to sort an array of structures.
Write a program to demonstrate nested structures.
Implement a structure with dynamic memory allocation.
Define a structure to store date and implement a function to compare two dates.
Define a structure to store complex numbers and implement addition and
subtraction.
Write a function to read and write a structure to a file.

File Handling

Write a program to read a file.


Write a program to write to a file.
Implement a program to append data to a file.
Write a program to read a file line by line.
Write a program to count the number of words in a file.
Write a program to copy contents of one file to another.
Implement a program to check if a file exists.
Write a program to delete a file.
Implement a program to read and display the contents of a binary file.
Write a program to merge two files into a third file.

Miscellaneous

Implement a simple calculator using functions.


Find the roots of a quadratic equation.
Implement a program to convert infix expression to postfix.
Implement a program to evaluate a postfix expression.
Write a program to find the transpose of a matrix.
Implement a program to multiply two matrices.
Write a program to find the determinant of a matrix.
Implement a program to check if a number is an Armstrong number.
Write a program to check if a number is a perfect number.
Implement a simple text-based menu system using functions.

Pointers and Dynamic Memory Allocation

Implement a function to create and initialize a dynamic array.


Write a program to demonstrate shallow copy and deep copy.
Implement a program to concatenate two dynamic strings.
Write a program to find the sum of all elements in a dynamic 2D array.
Implement a program to dynamically allocate and deallocate a linked list.
Write a program to demonstrate pointer to a structure.
Implement a program to dynamically create and destroy a binary tree.
Write a program to dynamically allocate and deallocate a stack.
Implement a program to dynamically allocate and deallocate a queue.
Write a program to resize a dynamic array.

Advanced String and Array Manipulations

Implement a program to find the longest common prefix among a set of strings.
Write a program to find the longest palindromic substring in a string.
Implement a program to find the longest increasing subsequence in an array.
Write a program to rotate an array by k positions.
Implement a program to find the kth smallest element in an array.
Write a program to find the maximum product subarray.
Implement a program to find the majority element in an array.
Write a program to find the minimum number of jumps to reach the end of an
array.
Implement a program to find the longest substring without repeating characters.
Write a program to solve the N-Queens problem.

You might also like