English

Write the program to display the following pattern: 1 2 3 4 56 7 8 910 11 1213 1415 - Computer Applications

Advertisements
Advertisements

Question

Write the program to display the following pattern:

1     2     3     4     5
6     7     8     9
10   11   12
13   14
15

Answer in Brief

Solution

public class Q9b
{ public static void main(String ar[])
{System.out.println("---------------------):
int i, j, p = 1;
for (i = 5; i >= 1; i--)
{ System.out.println();
for (j = i; j >= 1; j--)
{ System.out.print(p + "\t");
p++; 
}
}}
shaalaa.com
  Is there an error in this question or solution?
Chapter 1.1: Nested Loop - EXERCISES [Page 146]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 1.1 Nested Loop
EXERCISES | Q VI. 9. (b) | Page 146
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×