Computer Science, asked by sparshtaneja969, 7 months ago

What will be the output of the following program:

class Output

{ public static void main(String args[])

{ int a,b=0;

int c[]={1,2,3,4,5,6,7,8,9,10};

for(a=0;a<10;a++)

{if(a%2==0)

b+=c[a]; }

System.out.print(b);

}
}

What is the output of the code?​

Answers

Answered by Haruhi22
1

Answer:

25

As you are adding elements at even indices ,array is 0 based indexing

So ans=1+3+5+7+9

Similar questions