Sunday, April 19, 2009

A)Use for loops to construct a program that displays a pyramid of numbers on the screen.?

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%26#039;*%26#039; 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.

A)Use for loops to construct a program that displays a pyramid of numbers on the screen.?
for J = 1 to 4


for K = 1 to 6 - J


print %26quot; %26quot;


next K


for X = 1 to J


print J


next X


print %26quot;\n%26quot;


next J
Reply:please submit complete solution Report It

Reply:Really, you should do your own homework.





But the hint is a good one. I can%26#039;t really say anything else without giving it away... Look hard at the example and figure out what it%26#039;s doing.
Reply: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 %26quot;text%26quot; or string functions are available.


if the right functions are available, you could do this with a single loop (no nested loops required).



flower

No comments:

Post a Comment