Computer Science, asked by karantagra512, 8 months ago

#####
####
###
##
#
Write a program for this pattern in Java

Answers

Answered by chkomalath
1

import java.util.Scanner;public class Sample{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter the number of rows: "); int rows = sc.nextInt(); for (int i= rows-1; i>=0 ; i--) { for (int j=0; j<=i; j++) { System.out.print("#" + " "); } System.out.println(); } sc.close(); } }P

Answered by anindyaadhikari13
2

Question:-

Write a program in Java to display the following pattern.

#####

####

###

##

#

Program:-

import java.util.*;

class Pattern

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter the number of rows: ");

int n=sc.nextInt();

for(int i=n;i>=1;i--)

{

for(int j=1;j<=i;j++)

System.out.print("# ");

System.out.println();

}

}

}

Similar questions