English

Some of the code given below contains errors. Identify the error and correct it. Write the output of the correct/corrected code. int YM[] = { 512, 312, 452, 652, 782}; boolean all = true; for(int 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 YM[] = { 512, 312, 452, 652, 782};
boolean all = true;
for(int j = 0; j <5; j++)
{
   if(YM[j]%10 !=2)
   {
      all = false;
   }
}
System.out.print(" ALL =" + all);
Very Short Answer
Advertisements

Solution

No Error. Output : ALL = true

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. (vii) | Page 175
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×