Computer Science, asked by justheretocopy, 10 months ago

Find and correct the errors in the following program segment and then
predict the output:
int n[ ] = (2, 4, 6, 8, 10);
for (int i=0; i<=5; i++)
System.out.println(“n[“ + i +"]=“ + n[i]);

Answers

Answered by Vyomsingh
9

Answer:

Correct program:-

int n[]=[2,4,6,8,10];

for(int i=0;i<=4;i++)

System.out.println(i+“ ="+ n[i]);

OUTPUT:-

0=2

1=4

2=6

3=8

4=10

Answered by anindyaadhikari13
26

It's wrong.

Check out my answer,

int n[] = {2,4,6,8,10};

for(int i=0;i<=5;i++)

System. out. println("n["+i+"]="+n[i]);

Output:-

n[0]=2

n[1]=4

n[2]=6

n[3]=8

n[4]=10

&lt;marquee&gt;Hope it helps you...Please mark this answer as the brainliest and follow me..&lt;/marquee&gt;

Similar questions