PROGRAM: ARROW PATTERN
AIM: TO PRINT THE ARROW PATTERN
SUCH AS
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
SYNTAX:
import java.io.*;
class pattern_arrow
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("ENTER A NUMBER");
int n=Integer.parseInt(br.readLine());
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(j+" ");
}
System.out.println();
}
for(int i=n-1;i>=1;i--)
{
for(int j=1;j<=i;j++)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}
OUTPUT:
import java.io.*;
class pattern_arrow
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("ENTER A NUMBER");
int n=Integer.parseInt(br.readLine());
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(j+" ");
}
System.out.println();
}
for(int i=n-1;i>=1;i--)
{
for(int j=1;j<=i;j++)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}
Comments
Post a Comment