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 WH[] = {11, 22, 33, 44, 55, 66, 77};
int n = WH.length -1;
for(int j = 0; j<=n/2; j++)
{
int tmp = WH[j];
WH[j] =WH[n - j];
WH[j] =WH[n - j];
}
System.out.print(" The array is: ");
for(int j = 0; j<WH.length; j++)
System.out.print(" " + WH[j]);Very Short Answer
Advertisements
Solution
No Error. Output : The array is: 77 66 55 44 33 22 11
shaalaa.com
Is there an error in this question or solution?
Chapter 7: Arrays - One Dimension - Exercises [Page 176]
