Computer Science, asked by salinikumari130, 6 months ago

int i= 1;
int s[]= {2,4,6,7,8,9,10};
while(i<s.length)
{
System.out.println(s[i]+1);
if( i<s.length-3)
s[i+1]++;
i++;
}
state the output​

Answers

Answered by Anonymous
3

int[] z = new int[10];

It looks similar to defining a variable and actually it is. Here we are declaring 10 variables at one go.

Let's understand this

int[] z is representing that 'z' is an array of type integer ( as [ ] represents array ) and 'new int[10]' is representing that is it an array of 10 integers. In other words, we can say that 'z' is a collection of 10 integers.

Now, a question comes to mind, how to use these 10 variables?

The pictorial view is like this.

Each array has some array elements. In the above array example, there are 10 array elements.

0,1,2....8,9 are indices. It is like, these are the identities of 10 different array elements. Index starts from 0. So, the first element of the array has index 0, the second element has index 1 and so on.

Similar questions