Computer Applications
Declare and instantiate a one dimensional int array named evenNums with five elements. Use an initialiser list that contains the first five even integers, starting with 11.
Java Arrays
19 Likes
Answer
int evenNums[] = {12, 14, 16, 18, 20};
Answered By
11 Likes
Related Questions
Write a program to input integer elements into an array of size 20 and perform the following operations:
- Display largest number from the array
- Display smallest number from the array
- Display sum of all the elements of the array
How does the binary search find the presence of an element quicker than the linear search?
Suppose x is an array of type int[] with 50 elements. Write a code segment that will count and print the frequency of number 42 in the array.
A student wrote the following code segment, intending to print 11 22 33 44:
int arr[] = {11, 22, 33, 44}; for (int i = 1; i <= 4; i++) System.out.println(arr[i]);
However, the program crashed with a run-time error. Can you explain the reason for this?