Sure!
Here are 30 simple array practice problems in C++ to help you build your logic:
1. **Sum of All Elements**: Write a program to find the sum of all elements in an array.
2. **Average of Elements**: Write a program to find the average of all elements in an array.
3. **Maximum Element**: Write a program to find the maximum element in an array.
4. **Minimum Element**: Write a program to find the minimum element in an array.
5. **Reverse Array**: Write a program to reverse an array.
6. **Count Even and Odd Elements**: Write a program to count the number of even and odd elements
in an array.
7. **Find Second Largest Element**: Write a program to find the second largest element in an array.
8. **Count Positive and Negative Elements**: Write a program to count the number of positive and
negative elements in an array.
9. **Print All Distinct Elements**: Write a program to print all distinct elements in an array.
10. **Array Rotation**: Write a program to rotate an array by a given number of positions.
11. **Frequency of Elements**: Write a program to find the frequency of each element in an array.
12. **Pair with Given Sum**: Write a program to find pairs in an array whose sum is equal to a given
number.
13. **Missing Number**: Write a program to find the missing number in an array of consecutive
integers.
14. **Merge Two Arrays**: Write a program to merge two arrays into one.
15. **Check if Array is Sorted**: Write a program to check if an array is sorted in ascending order.
16. **Find Duplicates**: Write a program to find duplicate elements in an array.
17. **Remove Duplicates**: Write a program to remove duplicate elements from an array.
18. **Move Zeros to End**: Write a program to move all zeros in an array to the end without changing
the order of non-zero elements.
19. **Intersection of Two Arrays**: Write a program to find the intersection of two arrays.
20. **Union of Two Arrays**: Write a program to find the union of two arrays.
21. **Find Common Elements**: Write a program to find common elements in three sorted arrays.
22. **Segregate Even and Odd**: Write a program to segregate even and odd numbers in an array.
23. **Find the Smallest Missing Positive Integer**: Write a program to find the smallest missing positive
integer in an array.
24. **Kadane’s Algorithm**: Write a program to find the maximum sum subarray using Kadane’s
Algorithm.
25. **Rearrange Array Alternately**: Write a program to rearrange an array such that every second
element is greater than its previous and next element.
26. **Find Leader Elements**: Write a program to find all leader elements in an array (an element is a
leader if it is greater than all elements to its right).
27. **Find Equilibrium Index**: Write a program to find the equilibrium index of an array (an index
where the sum of elements on the left is equal to the sum of elements on the right).
28. **Cyclically Rotate Array**: Write a program to cyclically rotate an array by one.
29. **Subarray with Given Sum**: Write a program to find a subarray with a given sum.
30. **Replace Every Element with the Greatest Element on Right**: Write a program to replace every
element of an array with the greatest element on the right side.
These problems will help you strengthen your understanding of arrays and improve your logic-building
skills in C++. Happy coding!