//This Java program accepts a number from the

//user and prints a dual pyramid using 'a' of

//the number of layers entered by the user

//Sample input : 4

//Sample output : *

// * *

// * * *

// * * * *

// * * *

// * *

// *

import java.util.*;

class pattern

{

public static void main(String Args[])

{

int c,k,n,x,l;

System.out.println("Enter a number");

Scanner ob=new Scanner(System.in);

x=ob.nextInt();

l=x;

for(n=1;n<=x;n++)

{

for(c=l;c>1;c--)

{

System.out.print(" ");

}

for(k=1;k<=n;k++)

{

System.out.print("* ");

}

System.out.println();

l--;

}

int y;

for(n=x;n>1;n--)

{

for(y=n;y<=x;y++)

{

System.out.print(" ");

}

for(k=1;k<n;k++)

{

System.out.print("* ");

}

System.out.println();

}

}

}

//Author : Mayank Rajoria

//user and prints a dual pyramid using 'a' of

//the number of layers entered by the user

//Sample input : 4

//Sample output : *

// * *

// * * *

// * * * *

// * * *

// * *

// *

import java.util.*;

class pattern

{

public static void main(String Args[])

{

int c,k,n,x,l;

System.out.println("Enter a number");

Scanner ob=new Scanner(System.in);

x=ob.nextInt();

l=x;

for(n=1;n<=x;n++)

{

for(c=l;c>1;c--)

{

System.out.print(" ");

}

for(k=1;k<=n;k++)

{

System.out.print("* ");

}

System.out.println();

l--;

}

int y;

for(n=x;n>1;n--)

{

for(y=n;y<=x;y++)

{

System.out.print(" ");

}

for(k=1;k<n;k++)

{

System.out.print("* ");

}

System.out.println();

}

}

}

//Author : Mayank Rajoria

## No comments:

## Post a Comment