English

Some of the code given below contains errors. Identify the error and correct it. Write the output of the correct/corrected code. int DL[ ] = new int [5]; int n = 5; for(int j = 0; j<=n; 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 DL[ ] = new int [5];
int n = 5;
for(int j = 0; j<=n; j++)
    System.out.print(" " + DL[j]);
Code Writing
Advertisements

Solution

int DL[] = new int[5];
int n = 5;
for (int j = 0; j < n;j++) 
{
    System.out.print(" " + DL[j]);
}
shaalaa.com
  Is there an error in this question or solution?
Chapter 7: Arrays - One Dimension - Exercises [Page 176]

APPEARS IN

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

Englishहिंदीमराठी


      Forgot password?
Use app×