0% found this document useful (0 votes)
3 views1 page

Arrays

The document outlines a series of completed programming exercises focused on arrays, including tasks such as creating arrays, finding maximum values, and checking for palindromes. Each exercise provides a specific problem statement along with example input and output. The exercises cover various array operations, including searching, summing, and comparing elements.

Uploaded by

duttyusman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Arrays

The document outlines a series of completed programming exercises focused on arrays, including tasks such as creating arrays, finding maximum values, and checking for palindromes. Each exercise provides a specific problem statement along with example input and output. The exercises cover various array operations, including searching, summing, and comparing elements.

Uploaded by

duttyusman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Practice Exercises Arrays

1. Done : Write a program to create a simple array of 5 numbers and display the array.
2. Done : Write a program to create an array of 5 floats and display them
3. Done : Write a program to ask user to enter 5 numbers in a array, and find the maximum value
in array
a. Arr = [2,7,9,3,6]: Answer: 9
4. Done : Write a program to ask user to enter 5 numbers in an array, and find the second largest
value in array
a. Arr = [2,7,9,3,6]: Answer: 7
5. Done : Write a program to ask user to enter 5 numbers in a array, and find the index of
maximum value in array
a. Arr = [2,7,9,3,6]: Answer: 2 (9 exist on index 2)
6. Done : Write a program to assign 10 random numbers in an array and then ask user to enter a
number to find whether that number exists in the array or not using functions. (search number
in the array). Display index of the number of found else display -1.
a. Arr = [2,7,9,3,6]: Input = 7. Answer: 1
b. Input = 5: Answer = -1
7. Done : Write a program to sum all numbers of an array and display the sum
a. Arr = [2,7,9,3,6]: Answer: 27
8. Done : Write a program to find sum of all odd numbers in the array.
a. Arr = [2,7,9,3,6]: Answer: 10
9. Done : Find sum of all numbers on even indexes of the array.
a. Arr = [2,7,9,3,6]: Answer: 17 (2+9+6)
10. Done : Ask user to enter an array of 10 numbers and find whether the array is palindrome or
not. Palindrome is an array which is same whether it is read from start or from end. E.g.,
[1,3,5,5,3,1]

11. Done : Find the common numbers in two arrays.


a. Arr1 = [2,7,9,3,6]: Arr2 = [3,5,7,9,10]. Answer: 3, 7, 9

12. Done : Find the numbers that are different in two arrays
a. Arr1 = [2,7,9,3,6]: Arr2 = [3,5,7,9,10]. Answer: 2, 6,5,10

13. Done : Find the total number of occurrences of each number in array

14. Done : Write a program to ask user to enter 5 numbers in an array, and find the maximum
occurrences of each number in array
a. Arr = [2,7,9,3,2,6,9]: Answer: 2 = 2, 7 =1, 9= 2, …
15. Done : Write a program to reverse an array without using second array.
a. Arr = [2,7,9,3,6]: Answer: [6, 3, 9, 7, 2]

16. Write a program to insert all the numbers in sorted order is array.

You might also like