English

Find the errors in the following program snippet: for (int k = 1; k <= 10; k--) System.out.println(k); - Computer Applications

Advertisements
Advertisements

Question

Find the errors in the following program snippet: 

for (int k = 1; k <= 10; k--) 
      System.out.println(k);
One Line Answer

Solution

In the loop, the update expression should be k++.

shaalaa.com
  Is there an error in this question or solution?
Chapter 1.09: Iterative Constructs in Java - Review Insight [Page 120]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 1.09 Iterative Constructs in Java
Review Insight | Q 6. | Page 120
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×