Star printing program in java: pattern 6
Code for this pattern:
import java.util.Scanner;public class star {
public static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int n, i, k, j;
System.out.println("how many row you want : ");
n = sc.nextInt();
for(i=1;i<=n;i++)
{
for(k=0;k<=i;k++)
{
System.out.print(" ");
}
for(j=n;j>=i;j--)
{
System.out.print("*");
}
System.out.print("\n");
}
}
}
Try this in C.
Post a Comment