Java pattern in for initialization 97531 7531 531 31 1
Answers
Answered by
1
Answer:
Explanation:
import java.io.*;
public class Initialize
{
public static void main()throws IOException
{
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader in=new BufferedReader (isr);
System.out.println("Enter an odd number to see its pattern");
int a=Integer.parseInt(in.readLine());
int x=a-4;
for(int i=x;x>=1;i--)
{
for(int j=a;a>=1;j-=2)
{
System.out.print(j);
}
System.out.print(" ");
}
}
}
Similar questions