Computer Science, asked by Aniket9083, 1 year ago

Java pattern

9
97
975
9753
97531

Answers

Answered by Aishwarya98
15

java program to print the given pattern

Since the given numbers are odd: 1,3,5,7,9

we take the class name as odd.



class odd

{  

public static void main()

  for(int i=9;i>=1;i=i-2) 

 {     

for(int j=1;j<=4;j++) 


      {       


    System.out.print(" ");  


     }   


    for(int j=9;j>=i;j=j-2)        

{

                     if(j!=9)

                   {            System.out.print(j);

                        

}   

                     }        


System.out.println();

                 }        

}


}


Aishwarya98: mark me as brainliest..
Answered by ayush2124
4
using only one loop.

class brainli.ly.helpinghandtoyou
{
public static void main()
{
int i,t=0;
for(i=9;i>=1;i-=2)
{
t=t*10+i;
}
System.out.println(t);
}
}
Similar questions