Computer Science, asked by prashisharma, 8 hours ago

Write a program to print the
following pattern using nested for

98765
9876
987
98
9​

Answers

Answered by aryanb793
2

Answer:

hoping you will write starting of the program

I am answering only main part

Explanation:

int i,j ;

for( i=5 ; i<=9 ; i++)

{

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

{

System.out.print(j);

}

System.out.println();

}

Answered by udayagrawal49
0

Answer: The required java program is :-

public class Main {

 public static void main(String[] args) {

   for (int i=5 ; i<=9 ; i+=1) {

       for (int j=9 ; j>=i ; j-=1) {

           System.out.print(j);

       }

       System.out.println("");

   }

 }

}

Note :-

The above program is saved in a file named Main.java

Also, try-catch block can be used to avoid errors.

Similar questions