English

Predict the output: int k = 5; j; while (k >= 1) { j = 1 while (j <= k) { System.out.print(j); j++ } System.out.println(); k--; } - Computer Applications

Advertisements
Advertisements

Question

Predict the output:

int k = 5; j;
   while (k >= 1)
   {
      j = 1
   while (j <= k)
     {
     System.out.print(j);
     j++
     }
   System.out.println();
   k--;
   }
Answer in Brief

Solution

12345
1234
123
12
1

shaalaa.com
  Is there an error in this question or solution?
Chapter 1.1: Nested Loop - Review Insight [Page 143]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 1.1 Nested Loop
Review Insight | Q 6. | Page 143
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×