You are on page 1of 2

Practice Questions - Arrays

Semester: I

Subject: Learning C
Batch: 2013-16

Q1. Write a menu driven program to find the


a. Maximum element
b. Minimum element
c. Sum of all elements
d. Product of non zero elements
for an integer array.
Q2. Write a program to add the numbers stored at odd index locations.
Q3. Write a menu driven program to find the
a. Mean
b. Variance
c. Standard deviation
of the marks secured by the students of a class. The marks are stored in an array that
contains floating-point data.
Q4. Write a program to find the sum of a subset of the elements of an array. The starting and
the ending limits are to be accepted from the user.
Q5. Write a program to copy a subset of the elements of an array A to another array B. The
starting and the ending limits are to be accepted from the user. Take care of the array
bounds.
Q6. Modify the above program so that the offset where the data id to be stored in the second
array is also entered by the user.
Q7. Three floating-point arrays are used to store marks secured by students in three class
tests. The final marks secured by a student are to be calculated as the average of best-two.
Write a program that calculates the final marks and stores them in another array Results.
Q8. Modify the above program so that the individual marks are stored in a 2D array, rather
than three independent 1D arrays.
Q9. If a student is absent in a class then the marks secured by him/her are set to 1. In such a
case the marks of the student are calculated on the basis of those tests in which the
student appeared. Modify the above program to incorporate this condition.
Q10.

Write a program to calculate

a. Row-wise sum / average / minimum / maximum


b. Column-wise sum / average / minimum / maximum
of all elements of a 2D array.
Q11. Write a program to copy the ith row / column of a 2D array to a 1D array. (Take care of
the array bounds).
Q12. Write a program to copy a 1D array to the i th row / column of a 2D array. (Take care of
the array bounds).
Q13. Write a program to merge the contents of a 1D array A with those of another 1D array
B and store the results in a third 1D array C.

Page 1 of 2

Practice Questions - Arrays


Semester: I

Subject: Learning C
Batch: 2013-16

Q14. Modify the above program so that the starting and the ending points for the two source
arrays are accepted from the user.
Q15. A company store the information regarding the sales made for three of its products (PA,
PB and PC) by five of its salespersons (SP1, SP2, SP3, SP4, SP5) in four different zones
(N, E, S, W) in a 3D array. Here, the first dimension represents the products, the second
dimension represents the salespersons and the third dimension represents the zones. Write
down a menu driven program that generates:
a.
b.
c.
d.
e.

Total sales made.


Zone wise sales.
Product wise sales.
Sales made by each salesperson.
Sales made by a particular salesperson for each product. (Get salesperson number
form user)
f. Sales made by a particular salesperson in each zone. (Get salesperson number
form user)
g. Sales made by a particular salesperson for a product in a zone. (Get salesperson
number, product & zone form user)

Page 2 of 2

You might also like