English

Some of the code given below contains errors. Identify the error and correct it. Write the output of the correct/corrected code. int ZR[] = {0, 0, 0, 0, 0, 0, O}; ZR[0] = 2; for(int j =1; j <

Advertisements
Advertisements

Question

Some of the code given below contains errors. Identify the error and correct it. Write the output of the correct/corrected code.

int ZR[] = {0, 0, 0, 0, 0, 0, O};
ZR[0] = 2;
for(int j =1; j < ZR.length; j++)
{
      ZR[j] = ZR[j -1] * 2;
}
System.out.print(" The array is : ");
for(int j = 0; j < ZR.length; j++)
      System.out.print (" " + ZR[j]);

Very Short Answer
Advertisements

Solution

No Error. Output : The array is : 2 4 8 16 32 64 128

shaalaa.com
  Is there an error in this question or solution?
Chapter 7: Arrays - One Dimension - Exercises [Page 175]

APPEARS IN

Rupa Pandit Computer Applications [English] Class 10 ICSE
Chapter 7 Arrays - One Dimension
Exercises | Q 3. (ix) | Page 175
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×