Arrays Problems –
Write all programs considering size of array as ‘s’.
1. Find largest element in an array.
2. Find smallest element in an array.
3. Accept an integer ‘n’ and count number of elements equal to ‘n’.
4. Separate elements from array in three arrays which consists of all elements equal to ‘n’, less
than ‘n’ and greater than ‘n’.
5. Count odd elements and even elements in an array.
6. Count prime elements in an array.
7. Count positive and negative elements in an array.
8. Sort array elements in ascending order.(without changing original array)
9. Sort array elements in ascending order.(in the same array)
10. Write a program to add two arrays of order mXn.
11. Write a program to accept a scalar and array of size mXn. As an output display array after
scalar multiplication.
12. Calculate transpose of matrix of an array of size mXn.
13. Write a program to check if the array is a square matrix.
14. Check whether the entered matrix is square or not? If it is a square matrix display all
diagonal elements from array.
15. If the matrix is square matrix write a program to display upper diagonal elements and lower
diagonal elements.
16. Accept two matrices size and check if multiplication of these two is possible or not? If it is
possible display output after multiplication of two arrays.
17. Find second largest and third largest elements from array of size s.
18. Calculate addition of all elements in an array of size ‘s’.
19. Find maximum consecutive elements in an array of size ‘s’.
20. Display all pairs of elements and its squares in an array.
21. Search an integer in an array of size ‘s’. if found display its position in an array. If found at
multiple locations display all positions.
22. Find any 3 elements in array who give maximum product.
23. Remove element equal to ‘n’ from array.
24. Remove all duplicate elements from array of size ‘s’
25. Move all elements equal to ‘n’ at the starting positions of an array.
26. List all common elements from two arrays of size ‘s’.
27. List all unique elements from two arrays of size ‘s’. (elements that exist in one of the array
and avoid repetition of elements in result)
28. Combine elements from two arrays in a single array (without considering repetition of
elements in resultant array)
29. Define all possible subarrays with product less than ‘n’.
30. Arrange all elements odd and even in alternate manner in an array of size ‘s’.