Computer Science, asked by chiku8429, 5 months ago

print the following pattern:55555
54444
54333
54322
54321​

Answers

Answered by bshashank954
1

Answer:                                                                                                 Everything is going with an index from 1 to 5, so let's call it as i.

Then we have each iteration print out 5 times. So we need another index and let's call it as j.

It starts with 5, so we knew that index is iterating in reverse order.

It prints j from 5 to decreasing order. Once it reaches i, it stops decreasing.

Fill 5 digits and continue to next iteration.

In code, it will look like following:

for (int i = 5; i > 0; i--)  

{  

   for (int j = 5; j > i; j--)  

       System.out.print(j);  

 

   for (int j = i; j > 0; j--)  

       System.out.print(i);  

 

   System.out.println();  

}  

There you go.

Answered by cindrella113
7

Answer:

oo hello, I am not cheating.

this is not my test it is my friends hw

she is in different school okk..

dont answer if you dont know..

hope you understand

Similar questions