*
* *
* * *
* * * *
* * * * *
* * * * * *
First Way :
Code : -
class Pattern
{
public static void main(String[] s)
{
for(int i=0;i<6;i++)
{
for(int j=0;j<=i;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}
Second Way :
Code : -
import java.util.Scanner;
class Pattern
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int num = sc.nextInt();
System.out.println("Number is = "+num);
for(int i=0;i<num;i++)
{
for(int j=0;j<=i;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}
* * * * * *
* * * * *
* * * *
* *
*
Code : -
import java.util.Scanner;
class Pattern
{
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int num = sc.nextInt();
System.out.println("Number is = "+num);
for(int i=0;i<num;i++)
{
for(int j=0;j<num-i;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * * * *
Code:-
import java.util.Scanner;
class Pattern
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int n = sc.nextInt();
for(int i=0;i<n;i=i+2)
{
for(int j=0;j<n-1-i;j++)
{
System.out.print(" ");
}
for(int k=0;k<=i;k++)
{
System.out.print("* ");
}
System.out.println();
}
}
}
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * * *
Code :-
import java.util.Scanner;
class Pattern
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int n = sc.nextInt();
for(int i=0;i<n;i=i+2)
{
for(int j=0;j<n-1-i;j++)
{
System.out.print(" ");
}
for(int k=0;k<=1+i;k++)
{
System.out.print("* ");
}
System.out.println();
}
}
}
*
**
***
****
*****
****
***
**
*
import java.util.Scanner;
class Pattern
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int num = sc.nextInt();
System.out.println("Number is = "+num);
for(int i=0;i<num;i++)
{
for(int j=0;j<=i;j++)
{
System.out.print("*");
}
System.out.println();
}
for(int i=0;i<num;i++)
{
for(int j=0;j<num-i-1;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}
*
* *
* * *
* * * *
Code: -
import java.util.Scanner;
class Pattern
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int num = sc.nextInt();
System.out.println("Number is = "+num);
for(int i=0;i<num;i++)
{
for(int j=0;j<num-i-1;j++)
{
System.out.print(" ");
}
for(int k=0;k<=i;k++)
{
System.out.print("*");
}
System.out.println();
}
}
}
* * * * *
* * * *
* * *
* *
*
Code :-
import java.util.Scanner;
class Pattern
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int num = sc.nextInt();
System.out.println("Number is = "+num);
for(int i=num;i>0;i--)
{
for(int j=0;j<num-i;j++)
{
System.out.print(" ");
}
for(int k=0;k<=i-1;k++)
{
System.out.print("*");
}
System.out.println();
}
}
}
*
***
*****
*******
*********
*******
*****
***
*
Code:-
import java.util.Scanner;
class Pattern
{
public static void main(String[] s)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
int number = sc.nextInt();
for (int i=1; i<=number; i++)
{
for (int j=0; j<(number-i); j++)
{
System.out.print(" ");
}
for (int j = 1; j<=i; j++)
{
System.out.print("*");
}
for (int k=1; k<i; k++)
{
System.out.print("*");
}
System.out.println();
}
for (int i=number-1; i>=1; i--)
{
for (int j=0; j<(number-i); j++)
{
System.out.print(" ");
}
for (int j = 1; j<=i; j++)
{
System.out.print("*");
}
for (int k=1; k<i; k++)
{
System.out.print("*");
}
System.out.println();
}
}
}
No comments:
Post a Comment