package star;
import java.util.Scanner;
public class num1 {
public static void main(String[] args) {
int n, c, d;
Scanner in = new Scanner(System.in);
System.out.println("Enter the number of rows of triangle you want");
n = in.nextInt();
System.out.println("Triangle :-");
for ( c = 1 ; c <= n ; c++ )
{
for ( d = 1 ; d <= c ; d++ )
{
System.out.print(" "+d);
}
System.out.println();
}
}
}
import java.util.Scanner;
public class num1 {
public static void main(String[] args) {
int n, c, d;
Scanner in = new Scanner(System.in);
System.out.println("Enter the number of rows of triangle you want");
n = in.nextInt();
System.out.println("Triangle :-");
for ( c = 1 ; c <= n ; c++ )
{
for ( d = 1 ; d <= c ; d++ )
{
System.out.print(" "+d);
}
System.out.println();
}
}
}
No comments:
Post a Comment