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.
double KB[] = {3.12, 4.64, 5.57, 6.23, 7.25};
for( int j=0; j<= 5; j++)
KB[j] = (int)KB[j];
System.out.print("KB[2] =" + KB[2]);Code Writing
Advertisements
Solution
double KB[] = {3.12, 4.64, 5.57, 6.23, 7.25};
for (int j = 0; j < 5; j++) {
KB[j] = (int) KB[j];
}
System.out.print("KB[2] =" + KB[2]);
}shaalaa.com
Is there an error in this question or solution?
Chapter 7: Arrays - One Dimension - Exercises [Page 174]
