Arrays.
LOGICAL QUESTIONS ON ARRAYS.
-BY
VINEETH GODISHELA
(JAVA FULLSTACK TRAINER)
MOSTLY AVOID TO USE PREDEFINED METHODS TRY TO DO IT WITH
LOGICS
1. How to declare array
2. How to create integer array with elements:
3. How to create character array with elements
4. How to create array of string elements:
5. Find the length of Array
6. Display first element of integer type array
7. Display first element of String type array
8. Display last element of integer array.
9. Display last element of boolean type array.
10. Display first element of array only if the array has elements
11. Check the first element of integer array is Even
12. Check the last element of integer array is Positive
13. Display first element of integer array is Even or not only if it is positive.
14. Print the multiplication table for first element of integer array.
15. Check the last number of integer array is prime or not
16. Find the factorial for first element in integer array only if the element between 2 and 8
17. Check the first element bigger than second element in the given array.
18. Find the largest number of first 2 numbers in given array only if both elements are positive.
19. Program to find the sum of first and elements from given array.
20. Program to swap first element and last elements of array
21. Program to swap first element and last element of array without third variable.
22. Program to swap the index element with next element – Error if the next element is not
present.
23. Program to create integer array with size 5
24. Program to create integer array with given input size.
25. Program to display elements of array
26. Program to display array in reverse order
27. Program to display default values of array
28. Program to display array elements using for each loop.
29. Program to find the sum of array elements using for each loop
30. Program to find the sum of array elements using for loop
31. Program to display even numbers in the array using for each loop
32. Program to display odd numbers in the array using for loop
33. Program to calculate the average of array elements.
34. Program to find the sum of even numbers in the array using for each loop
35. Program to find the sum of odd numbers in the array using for loop
36. Program to print square value of each number in the array
37. Program to print the numbers which are higher than average of all elements in the array
38. Program to print the multiplication table of each number in the array
39. Program to find the factorial value for each number in the array.
40. Program to print the factors for each number in the given array.
41. Program to print factors count for each number in the given array.
42. Program to print only prime numbers in the given array
43. Program to print only perfect numbers in the given array
44. Program to display first even number in the given array
45. Program to display last odd number in the given array
46. Program to swap first even and last odd in the given array.
47. Program to find the index value of first even number
48. Program to find the index value of last odd number
49. Program to find the index value of largest element in array
50. Program to find the first occurrence of specified element in the given array
51. Program to find the last occurrence of specified element in the given array
52. Program to create new array with inserting element into specified location
53. Program to create new array by deleting specified index element
54. Program to find the first repeating element in the given array
55. Program to create new array by deleting first occurrence specified element in the array.
56. Program to create new array by deleting all occurrences of specified element in the array.
57. Program to find the index value of smallest element in array
58. Program to reverse all elements in the given array without second array.
59. Program to find the first non-repeating element in the given array.
60. Program to read the size of array from user and construct array object.
61. Program to read integers from end user and store into array
62. Program to find the smallest element in the array.
63. Program to find the biggest element in the array.
64. Program to find the mean element of array.
65. Program to check whether the element is duplicated or not in the array.
66. Program to search for an element in the array.
67. Program to pass array as parameter to method.
68. Program to return an array from the method.
69. Program to copy elements of one array into another array.
70. Program to display elements in array which are divisible by both 3 and 5
71. Program to find the average of array elements which are divisible by either 4 or 7
72. Program to find the common elements from 2 arrays.
73. Program to swap array elements of specified locations.
74. Program to search for an element (linear search)
75. Program to find the difference between 2 arrays of elements with same length.
76. Program to find the difference between 2 arrays of elements with different length
77. Program to find the sum of all elements in an array except for a given index.
78. Program to find the sum of all elements in an array except for the largest element.
79. Program to find the sum of all elements in an array except for the smallest element.
80. Program to find the sum of all elements in an array except for the first and last elements.
81. Program to find the sum of all elements in an array except for the first and second largest
elements.
82. Program to find the sum of all elements in an array except for the first and second smallest
elements.
83. Program to find the sum of all elements in an array except for the elements at even indices.
84. Program to find the sum of all elements in an array except for the elements at odd indices.
85. Program to find the difference between the largest and smallest elements in an array.
86. Program to find the difference between the second largest and second smallest
87. Program to construct array with only even numbers from given array
88. Program to constructor array with only odd numbers from given array
89. Program to construct 2 arrays with even and odd numbers from given array.
90. Program to merge two arrays
91. Program to find the sum of first negative & last positive number from the given array.
92. Program to sort array elements.
93. Program to find the duplicates in the array.
94. Program to arrange even numbers to left side and odd numbers to right side in the given
array.
95. Program to find the second largest element in the given array.
96. Program to test the equality of 2 arrays without using pre-defined method.
97. Program to move all zero to the end of given array.
98. Write a program to find the index difference between smallest and largest element of given
array.
99. Find the average value or array elements except smallest and largest element in that array.
100. Program to check array contains only positive numbers or not.
101. Program to find the sum of two elements in the array which is equal to the given number.
102. Program to print leader elements in the array.
103. Program to find the frequency of each number in the array
104. Program to find the missing number in an array of integers.
105. Program to sort an array of integers using the bubble sort algorithm
106. Program to find union of two arrays.
107. Find the non-repeated element in the given array
108. Program to find the intersection of two arrays.
109. Program to remove duplicates from an array of integers
110. Program to find the kth smallest element in an unsorted array
111. Program to find the kth largest element in an unsorted array
112. Program to find the maximum sum of 3 elements in an array
113. Program to find the minimum sum of 3 elements in an array.
114. Program to find the maximum subarray sum in an array
115. Program to find the minimum subarray sum in an array
116. Program to implement binary search on an array of integers.
117. Program to find the length of the longest increasing subsequence in an array
118. Program to merge 2 sorted arrays
119. Program to find the sum of all non-prime numbers in an array
120. Write a program to implement selection sort on an array of integers.
121. Write a program to implement insertion sort on an array of integers.
122. Write a program to implement merge sort on an array of integers.
123. Write a program to implement quicksort on an array of integers.
124. Write a program to implement heapsort on an array of integers.
125. program to find the length of the longest decreasing subsequence in an array
126. Program to find the sub array with given sum
127. Program to display pairs of given sum with array elements
128. Re-arrange the array with alternate even and odd numbers
129. Create the Wave array from the given array of elements
130. Find the third largest number in the given array
131. Program to declare two dimensional array element
132. Program to create 3x3 array with values
133. Program to display only first row elements in 3x3 matrix
134. Program to display only first column elements in 3x3 matrix
135. Write a program to create a 2D array of integers and print its elements in row-major order.
136. Write a program to create a 2D array of integers and print its elements in column-major
order.
137. Write a program to create a 2D array of integers and find the maximum element in it.
138. Write a program to create a 2D array of integers and find the minimum element in it.
139. Write a program to create a 2D array of integers and calculate the sum of all its elements.
140. Write a program to add 2 matrix
141. Write a program to multiply 2 matrix
142. Write a program to create a 2D array of integers and calculate the average of all its
elements.
143. Write a program to create a 2D array of integers and calculate the sum of each row and
print it.
144. Write a program to create a 2D array of integers and calculate the sum of each column and
print it.
145. Write a program to create a 2D array of integers and transpose it.
146. Write a program to create a 2D array of integers and sort it in ascending order.
147. Write a program to create a 2D array of integers and sort it in descending order.
148. Write a program to create a 2D array of integers and find the second largest element in it.
149. Write a program to create a 2D array of integers and find the second smallest element in it.
150. Write a program to arrange the elements in spiral matrix.