Write a code to print half rotated pyramid.
Vaishnavi Shrivastava
1 min read
Table of contents
import java.util.Scanner;
/**
* Link4
*/
public class Link {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("enter a number");
int n = sc.nextInt();
// System.out.println("enter a number");
// int m = sc.nextInt();
for (int i = 1; i <= n; i++) { //for outer loops , rows
for (int j = 1; j <=n-1; j++) {
System.out.print(" ");// for inner loops , columns
}
for (int j = 1; j <=i; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
0
Subscribe to my newsletter
Read articles from Vaishnavi Shrivastava directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by