You are on page 1of 1

Topic: Array

1. Write a java program that would input three numbers from the user and print sum, then the
first number, then the 2nd number followed by 3rd number. If user enters 10, 20, 30. Then output
should be 60, 10, 20, and 30.

2. Write a java program that reads 10 numbers from the user, and then prints them in the reverse
order.

3. Write a java program that reads 10 numbers from the user and prints the first even number in
the list. (Discuss how BREAK works in java)

4. Write a java program that would take 10 numbers input from user and store those numbers in
an array. Find the largest number and print it along with it's location.
Hint: For sample input 10, 30, 20, 50, 40, output will be "Largest number is 50 and found at
location 3".

5. Assume that we have the following array contains marks.


int[] marks = new int[] {10, 30, 20, 50, 40};
Find how many students are better than average and print their marks.

Output:
2 students are better than average.
They received following marks
50
40

Hint: First calculate average marks. Then loop through the marks array and count how many
marks are greater than average. Print this count. Then again loop through the marks array and
print those marks above average mark.

You might also like