Computer Science, asked by kadamsidharth8, 6 months ago

2)
1 point
Consider the following piece of code.
public class Main {
public static void main(String args[]) {
int a[] = {10, 20, 30, 40, 50, 60);
for (int i=0; i < a.length; i=i+2)
{
System.out.print("
" + a[i]);
}
}
}
Which of the following is an output of the above program?
a. 10 20 30 40 50 60
b. 10 30 50
c. 20 40 60
d. 10 30 50 60​

Answers

Answered by jaideepreddy9
0

Answer:

a. 10 20 30 40 50 60 is the answer.

Answered by anindyaadhikari13
1

Question:-

Write the output of the following code.

Solution:-

Given code,

public class Main {

public static void main(String args[])

{

int a[] = {10, 20, 30, 40, 50, 60);

for (int i=0; i < a.length; i=i+2)

{

System.out.print(" " + a[i]);

}

}

}

In this program, numbers in the odd position of the array will be printed.

So, output is:-

10 30 50

Output:-

10 30 50

Similar questions