ARRAY PROBLEMS ?
1. Write a program to store first N natural numbers in array A and make the array sum 0 by changing the sign of the numbers.

example
1. N=4
[ 1, 2, 3, 4]
The output
[ -1, 2, 3, -4] = sum is zero
[ 1, -2, -3, 4] = sum is zero




ANSWER...

2. write a program to read N no. of values in order and search a particular value x using binary search method.

ANSWER...

3. write a program to read N number of values in to an array a and find the sum of odd values present in the array.

ANSWER...

4. Write a program to read N number of elements and rearrange the elements in the order of odd elements following even elements.
Example: 5 no. of values
1, 4, 3, 7,10
4,10, 1, 3, 7

ANSWER...

5. write a program to read N number of values in to an array a and find, print the smallest value.

ANSWER...

6. write a program to read N number of values in to an array a and print only second half values of array a.

ANSWER...

7. Leaders in an Array
An element is a leader if it is greater than all the elements to its right. Print all leaders in the array.
Example :
INPUT : 6
ELEMENTS ARE : 4,8,10,4,5,9
OUTPUT : 10, 9

ANSWER...

8. write a program to read N number of values and store it in an array a. print all values of array a.

ANSWER...

9. write a program to read N no. of values in to an array A, M no. of values in to an array B. Combine A and B array values in to C.print the resultant array C.

ANSWER...

10. write a program to read N number of values and store it in an array a. print only odd values of array a.

ANSWER...

11. Write a program to read n no. of values and distribute the values into array b and c in such a way that their sums are almost equal or near to equal.

ANSWER...

12. Write a program to store N different numbers into array a and print all possible pairs with the array values without duplicates.

ex. array A = [ 1, 5, 6, 8, 9 ]
The possible pairs are
(1,5)
(1, 6)
(1,8)
(1,9)
(5,6)
(5,8)
(5,9)
(6,8)
(6,9)
(8,9)

ANSWER...

13. Rearrange Array in Zig-Zag Fashion
Given an array, rearrange the elements such that a < b > c < d > e ....
Example :
INPUT : 6
ELEMENTS ARE : 15,10,1, 8,4,12
OUTPUT : 10, 15, 1, 8, 4,12

ANSWER...

14. write a program to read N number of values in to an array a and print only first half values of array a.

ANSWER...

15. Subarray with Given Sum
Write a program to find if there exists a contiguous subarray with a given sum K.
Example :
INPUT : 7
ELEMENTS ARE : 8, 5, 3, 2,5,4,1
SUM = 10
OUTPUT : 5,3,2
3,2,5
5,4,1

ANSWER...

16. write a program to read N number of values in to an array a and print the sum of first half values, product of second half values of array a.

ANSWER...

17. Write a program to read N number of values in array a and print the value which is least less than the sum of two smallest numbers and not present in the array.

ANSWER...

18. write a program to read N no. of values and check the given values are in ascending/descending order or not. if values are in order print the message "ARRAY IS IN ORDER"

ANSWER...

19. write a program to read N number of values in to an array a and find, print the second greatest value.

ANSWER...

20. Write a program to store N number of value in to array A, M number of values in to array B.
Find, print the Union of A and B, Intersection of A and B.

A = [ 1, 5, 7, 9 ]

B = [5, 7,10, 15]

The union of A, B is = [ 1,5,7,9,10,15]

The intersection of A, B is = [ 5, 7 ]

ANSWER...

21. Write a program to store N number employee data(employee no, name, designation and salary) in to an array A using object concept. print the employee who get the highest salary among its designation employees. [ please remember the highest salary is calculated among its designation employees, not of all employees]
for example
emp. No emp name designation salary

345 ABHINA CLERK 15000
347 HINA CLERK 35000
349 BHINA OFFICER 25000
450 ABHA CLERK 45000
545 RYAN OFFICER 50000
550 HYNA CLERK 38000


The output should be

CLERK [ highest salary ]
450 ABHA CLERK 45000

OFFICER [ highest salary ]
545 RYAN OFFICER 50000




ANSWER...

22. Write a program to read N different arrays and to print the largest sum array. The largest sum array is an array in which elements sum is the largest among its counterparts.

ANSWER...

23. write a program to read N number of values and store it in an array a. print only even values of array a.

ANSWER...

24. write a program to read N number of values in to an array a and count the number of positive, negative, and zero values present in the array.

ANSWER...

25. Write a program to store N number of ordered values in to array A, M number of ordered values in to array B. Merge A and B into array C. [ Rules, 1. the array to be scanned only once while merging 2. No order method to be used.]

ANSWER...

26. Write a program to read N number of elements and rearrange all the values in order using insertion sort method.

ANSWER...

27. write a program to read N number of values in to an array a and search a particular input value(x) is present in the array or not. if present print the message 'Found' otherwise print 'Not Found'.

ANSWER...

28. Write a program to read N number of elements and rearrange all the values in order using selection sort method.

ANSWER...

29. write a program to read N number of values in to an array a and rotate the array values one location up.

ex : array a values
1, 2, 3, 4, 5

after rotation the array values should be
5, 1, 2, 3, 4

ANSWER...

30. Write a program to read N number of elements and find the frequency of each value in the array.

Ex. array A values = 5, 10, 5, 20, 15, 10, 30, 20,5,10, 20, 30,10,

The output should be
5 -> 3 times
10 -> 4 times
20 ->3 times
15 -> 1 time
30 -> 2 times

ANSWER...

31. Write a program to store N number students data(rno, name, and mark) in to an array A using object concept. print the student object data who got the highest mark.

ANSWER...

32. write a program to read N number of values in to an array a and rearrange all values of array in ascending order.

ANSWER...

33. write a program to read N number of values in to an array a and rearrange all values of array in descending order.

ANSWER...

34. Write a program to read N number of values and print the missing numbers.
Example : 5 no. of values
10, 4, 7, 9, 6
OUTPUT : The missing elements are
5, 8

ANSWER...

35. write a program to read N number of values in to an array a and find the sum of all values of array.

ANSWER...

36. Write a program to read N number of elements and rotate the array by k elements to the right if k is positive, otherwise rotate towards left.

ANSWER...

37. write a program to read N number of values in to an array a and find the sum of even values present in the array.

ANSWER...

38. write a program to read N number of values in to an array a and find, print the greatest value.

ANSWER...

39. Write a program to read N number of values in an array and print each value and its all possible combination of products of array values except itself.
Example : 5 number of values
12, 2, 3, 6, 4
OUTPUT : 12 = 3 x 4
6 x 2
6 = 2 x 3

ANSWER...

40. write a program to read N no. of values and print only duplicate elements.

ANSWER...

41. write a program to read N number of values in to an array a and print all values of array a in reverse.

ANSWER...

42. Write a program to read two different arrays name A & B and find out the two array is anagram of each other.

ANSWER...

43. write a program to read N no. of values in order and insert a particular value x at its appropriate place.
Ex. the 5 values in array are 5, 10, 15, 20, 25
the insertion value is 12
the array after insertion is
5, 10, 12, 15, 20, 25

ANSWER...

44. Write a program to read N number elements and rearrange the –ve elements in descending using insertion sort and +ve elements in ascending using selection sort.

ANSWER...

45. Write a program to store N number students data(rno, name, and mark) in to an array A using object concept. print the student object data in order as per their mark.


ANSWER...

46. write a program to read N number of values in to an array a and print only prime numbers.

ANSWER...

47. write a program to read N number of values in to an array a and count the number of positive values present in the array.

ANSWER...

Hungry Minds


HUNGRY MINDS
REG.NO. 09AKEPV9632M2Z9
Regd. Office : 120, Khirighat, Basti - 272002,
Uttar Pradesh , India.

Branch Office : No 91, Vallalar Nagar, V.M. Chatiram,
Tirunelveli - 627011, India

Our Services

School Software

Payment Gateway

Church Management Software

Mobile Apps

Ecommerce Site Development

Robotics Classes



hungryminds.basti@gmail.com

vasantharaj1972@gmail.com

- 2024 Copyright is Reserved. Hungry Minds 7796, India - 7985872766.