Write a Program to print the following pattern.

Q.10 Write a Program to print the following pattern.

Solution  :- 

public class Star {
public static void main(String[] args) {
int n = 5; // Number of rows

for (int i = 1; i <= n; i++) {

for (int j = 1; j <= i; j++) {
System.out.print(“* “);
}

System.out.println();
}
}
}

Output :- 

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.