You are here:

C/CC++ Java

Advertisement


Question
Write 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

Answer
Hello 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.

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Zlatko

Expertise

No longer taking questions.

Experience

No longer taking questions.

Education/Credentials
No longer taking questions.

©2012 About.com, a part of The New York Times Company. All rights reserved.