C/CC++ Java
Expert: Zlatko - 6/10/2010
QuestionWrite a program to implement a method display(int n)
1.For example if n = 4, the output should be
i. 4,3,2,1
ii.3,2,1
iii.2,1
iv.1
AnswerHello Yaadi.
You will need 2 loops, one within the other. The outer loop has to count from n down to 1. It will take care of entire lines. The inner loop should also count from the value of the outer loop counter down to 1. It will take care of the characters in each line. For each count in the inner loop, print out the inner loop counter. Whenever the inner loop is done, print out a newline character. Does that make sense ?
Now, try to write the code. Show me an attempt at the code and I'll give you some feedback.
Do you really need the Roman numerals (i, ii, iii) printed out ?
Best regards
Zlatko.