C Programming Array Exercise for Practice

The array is one of the most important topics for programming interviews. It doesn't matter if you are going to Google, Microsoft, Amazon or even service based companies like IBM,Accenture, TCS, or Infosys, if you are going to interview for the developer position, you must prepare array very well. In fact, it is the second most topic after String and if you look closely, String coding problems can be solved by treating them like character array.
An array is a one of the data structure in C, that can store a fixed-size sequential collection of elements of the same data type. It is also known as static data structure because size of an array must be specified at the time of its declaration. An array gets memory in heap area and Index of array starts from zero to size-1.


For many large applications, there may arise some situations that need a single name to store multiple values. To process such large amount of data, programmers need powerful data types that would facilitate the efficient contiguous bulk amount of storage facility, accessing and dealing with such data items. So, array is used.

List Of C Programming Array Problems for Practice

1. Write a C program to read and print elements of array. - using recursion.
2. Write a C program to print all negative elements in an array.
3. Write a C program to find sum of all array elements. - using recursion.
4. Write a C program to calculate the average value of array elements.
5. Write a C program to test if an array contains a specific value.
6. Write a C program to find the index of an array element.
7. Write a C program to find maximum and minimum element in an array.
8. Write a C program to find second largest element in an array.
9. Write a C program to find the second smallest element in an array.
10. Write a C program to count total number of even and odd elements in an array.

11. Write a program to count total number of negative elements in an array.
12. Write a program to copy all elements from an array to another array.
13. Write a program to insert an element in an array.
14. Write a program to delete an element from an array at specified position.
15. Write a program to find the duplicate values of an array of integer values.
16. Write a program to print all unique elements in the array.
17. Write a program to count total number of duplicate elements in an array.
18. Write a program to delete all duplicate elements from an array.
19. Write a program to merge two array to third array.
20. Write a C program to reverse an array of integer values.
21. Write a program to put even and odd elements of array in two separate array.
22. Write a program to search an element in an array.
23. Write a program to sort array elements in ascending or descending order.
24. Write a program to sort even and odd elements of array separately.
25. Write a program to left rotate an array.
26. Write a program to right rotate an array.
27. Write a program to find the common elements between two arrays (string values).
28. Write a program to find the common elements between two arrays of integers.

29. Write a C program to print the pattern-
       * * * * * * *
       * * * * * * *
       * * * * * * *
       * * * * * * *
30. Write a C program to print the pattern-
       *
       * *
       * * *
       * * * *
       * * * * *
31. Write a C program to print the pattern-
       * * * * *
       * * * *
       * * *
       * *
       *
33. Write a C program to print the pattern-
                       *
                    *   *
                  *   *   *
                *   *   *   *
              *   *   *   *   *

List of matrix programming exercises :

34. Write a C program to add two matrices.
35. Write a C program to subtract two matrices.
36. Write a C program to perform Scalar matrix multiplication.
37. Write a C program to multiply two matrices.
38. Write a C program to check whether two matrices are equal or not.
39. Write a C program to find sum of main diagonal elements of a matrix.
40. Write a C program to find sum of minor diagonal elements of a matrix.
41. Write a C program to find sum of each row and column of a matrix.
42. Write a C program to interchange diagonals of a matrix.
43. Write a C program to find upper triangular matrix.
44. Write a C program to find lower triangular matrix.
45. Write a C program to find sum of upper triangular matrix.
46. Write a C program to find sum of lower triangular matrix.
47. Write a C program to find transpose of a matrix.
48. Write a C program to find determinant of a matrix.
49. Write a C program to check Identity matrix.
50. Write a C program to test the equality of two arrays.
51. Write a C program to find a missing number from 1-9 in an array.

Some Hard Problems :

52 . Write a C program to move all 0's to the end of an array. Maintain the relative order of the other (non-zero) array elements.
53.Write a C program to get the difference between the largest and smallest values in an array of integers.
54. Write a C to check if an array of integers contains two specified elements 65 and 77.
55. Write a C program to check if the sum of all the 10's in the array is exactly 30. Return false if the condition does not satisfy, otherwise true.

56. Write a C program to remove the duplicate elements of a given array and return the new length of the array.
Sample array: [20, 20, 30, 40, 50, 50, 50]
After removing the duplicate elements the program should return 4 as the new length of the array

57. Write a V program to find the length of the longest consecutive elements sequence from a given unsorted array of integers.
Sample array: [49, 1, 3, 200, 2, 4, 70, 5] 
The longest consecutive elements sequence is [1, 2, 3, 4, 5], therefore the program will return its length 5.

58. Write a C program to find the sum of the two elements of a given array which is equal to a given integer.
Sample array: [1,2,4,5,6 
Target value: 6.

59Write a C program to find all the unique triplets such that sum of all the three elements [x, y, z (x ≤ y ≤ z)] equal to a specified number.
Sample array: [1, -2, 0, 5, -1, -4]
Target value: 2.

Thanks for reading this article "C Programming array problems for practice" so far. If you like this article then please share with your friends and colleagues. If you have any question or doubt then please let us know and I'll try to find an answer for you.


Incoming Searches : C array questions, array practice question, array problems for practice, programming exercise for practice, array in C