#####
####
###
##
#
Write a program for this pattern in Java
Answers
Answered by
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
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
English,
4 months ago
Math,
4 months ago
Computer Science,
11 months ago
Computer Science,
11 months ago