English

Write the program to display the following pattern: 1 2 34 5 67 8 9 1011 12 13 14 15 - Computer Applications

Advertisements
Advertisements

Question

Write the program to display the following pattern:


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

Answer in Brief

Solution

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

APPEARS IN

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

Englishहिंदीमराठी


      Forgot password?
Use app×