Wednesday, January 18, 2023

Array practice problems and Solutions

1D Array-related problems.

1. Write a program to print a string using an array.

2. Write a program to find the sum of negative and positive integers.

3. Write a program to find the sum of N numbers in an array

4. Write a program to find the smallest element in the array

5. Write a program to find the largest element in the array

6. Write a program to find the 2nd smallest element in the array

7. Write a program to find the 2nd largest element in the array

8. Write a program to Print the Average of Numbers in array at an even position

9. Write a program to Print the Average of Numbers in array at an odd position

10. Write a program to print array elements in reverse order.

11. Write a program to print array elements in reverse order using the swapping method.

12. Write a program to separate even and odd numbers in an array.

13. Write a program to print the frequency of all numbers in an array.

14. Write a program to print the most occurring elements.

15. Write a program to separate even and odd position numbers in an array.

16. Write a program to separate positive and negative numbers in an array.

17. Write a program to print lists of occurring elements in an array.

18. Write a program to insert an element into an array at a specified position

19. Write a program to delete a specified integer in an array

20. Write a program to search a specified integer in an array

21. Write a program to find the array type

22. Write a program to sort the elements of an array

23. Write a program to count distinct elements of an array

24. Write a program to remove duplicate elements in an array

25. Write a program to check if two arrays are the same or not.

26. Write a program to check if one array is a subset of another array or not.

27. Write a Program to Find the index of an element in an array.

28. Write a Program to Sort an array in Descending order.

29. Write a Program to Merge two unsorted arrays of different lengths.

30. Write a Program to remove an element from an array by index.

31. Write a Program to Move all zeros to the end of an Array.

32. Write a Program to Move all zeros to the Start of an Array.

33. Write a Program to Find the mean and median of an unsorted array.

34. Write a Program to Find the maximum product of 3 numbers in an array.

35. Write a Program to Find missing numbers in an array.


Matrix or 2D Array-related problems.

1. Write a Program to read and display a Matrix.

2. Write a Program to Find the sum of all elements in a 2d array or Matrix.

3. Write a Program to find the addition of two matrices.

4. Write a Program to find the multiplication of two matrices.

5. Write a Program to the Subtraction of two matrices.

6. Write a Program to print the square of each element of the 2d array or matrix.

7. Write a Program to accept two matrices and check whether they are equal or Not.

8. Write a Program to find whether the given is the matrix is diagonal or not.

9. Write a Program to find the sum of all diagonal elements of a matrix.

10. Write a Program to find the maximum element in the matrix.

11. Write a Program to find the minimum element in the matrix.


No comments:

Post a Comment