Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C (http://www.programmingforums.org/forum60.html)
-   -   arrays?? (http://www.programmingforums.org/showthread.php?t=15464)

FengLing Mar 23rd, 2008 8:56 AM

arrays??
 
can anyone try to help me getting an output like this:

ull be able to input a number for example..

12 and its output is like this...

12 11 10 9 8 7 6 5 4 3 2 1
11 10 9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2 1
....................
..................
...................
3 2 1
2 1
1

i'm a noob programmer and can't figure how to start please help me thanks in advance...

Ooble Mar 23rd, 2008 8:59 AM

Re: arrays??
 
You'll need what's called a nested loop. You have one loop that counts down from 12 to 1, and inside that loop have another loop that counts down from the value of the iteration you're in to 1. The logic goes something like this:
:

loop from i = 12 to 1
    loop from j = i to 1
        print j
    end loop
    print newline
end loop


FengLing Mar 23rd, 2008 9:22 AM

Re: arrays??
 
ouch still can't follow... Ooble can u do the whole loop?

OpenLoop Mar 23rd, 2008 10:21 AM

Re: arrays??
 
You'll need to show some effort FengLing. What Ooble told you should be enough to get you started on some code. Where is your code?

FengLing Mar 23rd, 2008 10:35 AM

Re: arrays??
 
pls. help jst limit the number to 3

3 2 1
2 1
1

so that i can get a little idea...

FengLing Mar 23rd, 2008 10:46 AM

Re: arrays??
 
OpenLoop can u translate the sample of Ooble to C...

OpenLoop Mar 23rd, 2008 10:49 AM

Re: arrays??
 
Quote:

Originally Posted by FengLing (Post 142814)
OpenLoop can u translate the sample of Ooble to C...

No I can't. What I can translate is what I said earlier, WE DONT DO YOUR HOMEWORK FOR YOU. Read the rules and show some effort, any effort past posting a question.

FengLing Mar 23rd, 2008 11:24 AM

Re: arrays??
 
ok then what loop statement should i use?...

OpenLoop Mar 23rd, 2008 12:15 PM

Re: arrays??
 
a For loop will do.

Benoit Mar 23rd, 2008 12:21 PM

Re: arrays??
 
A 'for' loop is most appropriate for this situation. You will need two of them - a loop within a loop.


All times are GMT -5. The time now is 4:19 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC