English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hints
You may nest two inner loops, one to print spaces and one to print numbers (0-9), inside an outer loop that steps down the screen from line to line.
ask user to enter the number if he enter 3 out put will be.
*****1
****2 2
***3 3 3
**4 4 4 4
In the above sample there will no'*' in real and it is not appear in screan . it will write only for submitting sample.if I do not write * prew of sample is not correct in appearence.

2006-10-25 19:01:12 · 3 answers · asked by Muhammad A 1 in Education & Reference Higher Education (University +)

3 answers

for J = 1 to 4
for K = 1 to 6 - J
print " "
next K
for X = 1 to J
print J
next X
print "\n"
next J

2006-10-25 19:21:44 · answer #1 · answered by AardVark 2 · 0 0

proper formatting gets a little more complicated if you allow your list to go beyond 9 (two digit numbers, three digit numbers, etc.)

this task may be easier in some programming languages than in others, depending on what "text" or string functions are available.
if the right functions are available, you could do this with a single loop (no nested loops required).

2006-10-25 19:18:18 · answer #2 · answered by Anonymous · 0 0

Really, you should do your own homework.

But the hint is a good one. I can't really say anything else without giving it away... Look hard at the example and figure out what it's doing.

2006-10-25 19:08:12 · answer #3 · answered by Ryan 4 · 0 0

fedest.com, questions and answers