You are on page 1of 2

Arrays Lab Exercise

1. Input a single dimension array, sort the elements in the ascending order and display the elements

2. Input an array of 15 elements and display the position of the maximum and minimum elements in the
array

3. Input an array of 15 elements and display the sum of the elements

4. Input an array of 10 elements and sort the array in both ascending and descending order and display the
sorted array along with the original array

5. Get user input for an array of 25 elements. The condition is that the user should be allowed to enter only
values in the range of 1 to 5. He should not be allowed to enter any

other value nor should the program exit before getting all the elements of the array.

6. For the above array find the mean and median and print the result.

7. Input an array of 25 elements. Find the mode[frequency] of the elements occurring in the array and display
them eg.

a. 1 Occur 4 times

b. 2 Occurs 3 times

c. 3 Occurs 7 times

d. 4 Occurs 5 times

e. 5 Occurs 6 times

8. Print a histogram – bar chart for the above problem.

9. Input 5 subject mark for 10 students and display the marks in a tabular format with each students total and
average along with class average for cash subject and also his or her grade as follows

Roll no Name Maths English Physics Chemistry Bio Total Average

100 Das 99 90 80 95 90 454 90.8

10. Input a 2 dimensional array of size 5 X 5 and display the sum of the rows and columns.

11. Input 2 x 2 dimensional matrix’s and display their sum.

12. For the above problem do matrix subtraction and display the difference.

13. Input 2 matrix of 3 x 3 size. Multiply them and display the results.

14. Input a 5 x 5 matrix and add the sum of the columns and also the sum of the rows correspondingly and
display the results.

15. Find the transpose of a matrix.


String Exercises

1. Input a string and find its length.

2. Input a string and reverse it and display the same.

3. Input a string from the user and find whether it is a palindrome or not

4. Input a string from the user and copy it into another string and display the same.

5. Input two string from the user and concatenate them and the same

6. Input two strings and compare them and display if they are the same.

7. Input a string and copy only the first n characters into another array. N is to be got from

the user.

8. Input a string and copy only the last n characters into another array. N is to be got from

the user.

9. Input a paragraph with at least 5 lines from the user and convert the uppercase letters and

lower case into upper case and display the output.

10. Input a paragraph with at least 5 lines from the user and also input a string from the user

and find the number of occurrences of the string in the paragraph.

11. Input a paragraph with at least 5 lines from the user and also input a string from the user

and delete the occurrences of the string in the paragraph.

12. Input a paragraph with at least 5 lines from the user and also input a string from the user

and replace the occurrences of the string in the paragraph with another string got from the

user.

13. Input a list of 10 names and sort the names in the alphabetical order.

14. Input 10 names with each name containing the first and last names in full and then print

the names with the first name’s initial and the last name in full in ascending order. Sort

according to the last name.

15. Input a paragraph and count the number of lines, blank spaces, consonants, vowels.

You might also like