English

Write the program to display the following pattern: 5 4 3 2 15 4 3 2 5 4 35 45 - Computer Applications

Advertisements
Advertisements

Question

Write the program to display the following pattern:

5     4     3     2     1
5     4     3     2     
5     4     3
5     4
5

Answer in Brief

Solution

public class Q9h
{ public static void main(String ar[])
{ System.out Println("\n-----------------------");
int i, j;
for (i = 1; i <= 5; i++)
{System.out.println();
for (j = 5; >= i; j--)
System.out.print(j + " ");
}}
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. (h) | Page 147
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×