0% found this document useful (0 votes)
91 views1 page

Java Program for Star Pattern Printing

This Java code uses nested for loops and a Scanner to print out a triangular pattern of asterisks. The outer for loop iterates from 1 to the input number, while the inner loop prints asterisks from that number down to the current iteration of the outer loop. This creates a triangle where each subsequent line has one less asterisk printed.

Uploaded by

Rutikesh Shetye
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views1 page

Java Program for Star Pattern Printing

This Java code uses nested for loops and a Scanner to print out a triangular pattern of asterisks. The outer for loop iterates from 1 to the input number, while the inner loop prints asterisks from that number down to the current iteration of the outer loop. This creates a triangle where each subsequent line has one less asterisk printed.

Uploaded by

Rutikesh Shetye
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import java.util.

Scanner;
public class pattern3 {
public static void main(String[] args){
Scanner op = new Scanner(System.in);
int a = op.nextInt();
for(int i=1;i<=a;i++){
for(int j=a;j>=i;j--){
System.out.print("* ");
}
System.out.println();
}
}
}

// * * * * *
// * * * *
// * * *
// * *
// *

You might also like