Array:: Sample Input 1
Array:: Sample Input 1
1)
Write a java program to create an array of size ‘n’ and accepts ‘n’ number of integers from the user and display
all the values from an array in reverse order
Sample Input 1
46
83
67
Sample Output 1
67
83
46
2)
Write a java program to find the given number from the array of elements and display its position. If the number
is not present in an array then display it as 0.
32
17
17
Sample Output 1
3)
Sample Input 1
16
77
83
Sample Output 1
16
77
83
4)
Write a java program to sort the values from the array of elements in descending order
Sample Input 1
26
10
416
92
Sample Output 1
416
92
26
10
7
5)
Anjali gets n numbers in an array. Write a Java program to print the sum of the maximum and the minimum
element in the array.If the size of an array is 0 or less print "Invalid Array Size".
Sample Input 1:
45
23
48
90
89
Sample Output 1:
113
Sample Input 2:
Sample Output 2:
Invalid Array Size
6)
Interchange the elements of an array
Write a Java program to interchange the elements of an array with the elements of another array without using
the third array.If the array size differs display "Unable to swap size differs".If the range is lesser or equal to Zero
. Display "Invalid range "
Sample Output 1:
The first array after swapping is :
456
The second array after swapping is :
123
Sample Input 2:
-3
Sample Output 2:
Invalid range
Sample Input 3:
2
Sample Output 3:
7)
Sum of factorial of positive and single digit numbers in an array
Write a java program to find the sum of factorial of the numbers in an array. Consider the number for finding
the factorial only if it is positive and single digit. If not print "No positive and single digit numbers found in an
array".
Sample Input 1:
-56
-13
56
Sample Output 1:
722
8)
Sort the first and second half of an array
Anjali likes to play mathematical tricky games .She gets n numbers for an array. Help Anjali to write a Java
program to sort the first half of the array in ascending order and the second half of the array in descending
order. If the size of the array is 0 or lesser then display the message as "Array size should be greater than 0".
Sample Input 1:
89
23
56
12
99
Sample Output 1:
23
56
89
99
12
Sample Input 2:
Sample Output 2:
Array size should be greater than 0
9)
Array Compatiblilty
Two arrays are said to be compatible if they are of the same size and if the ith element in the
first array is greater than or equal to the ith element in the second array for all i elements.If the
array size is zero or lesser then display the message "Invalid array size".Write a Java program
to find whether 2 arrays are compatible or not.If the arrays are compatible display the message
as "Arrays are Compatible" ,if not then display the message as "Arrays are Not Compatible".
Sample Input 1:
14
17
19
15
15
Sample Output 1:
Sample Input 2:
Sample Output 2:
Sample Input 3:
-2
Sample Output 3:
Numerology
Write a program to find the numerological value for a given name.
Note: Store the numerological number and the corresponding character in a 2-D array(2*26). Always the
given name should be in capital case ,else the name is not valid. Check for the valid name,if the name is
invalid print the message "Invalid name".There should not be any space in the name provided.
For example:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
12345835112345781234666517
Sample Input 1:
Enter your name:
SUDHA
Sample Output 1:
Sample Input 2:
Enter your name:
kiran
Sample Output 2:
Invalid name
Sample Input 3:
Enter your name:
ANI34
Sample Output 3:
Invalid name