hi ive been workingon some For loops an While Loops and Switch statements and i need so help with this one problem if you could help me that would be grate ive tried realy hard to do this on my own but cant figure it out thanks for helping

This is the frist one i need help with is how to print this uesing For loops

13579
1357
135
13
1


and this other one by useing If/Else i think

I have..........10 exercise routines left for the month!

I think you should post in the programming section designated for php coding you would probably get more hits. It is in the forum index underneath scripting languages.

u must do something about ur programming concept. i meam, if u find this prog. to be tough then what about the tougher ones that are waiting for u in the near future.
to print the following format using for loop
13579
1357
135
13
1

u can take help of a nested loop
first start a for loop (say i) from (1 to c), where c=9, in the first case
and then inside that for loop create anothe for loop from (say j) (1 to i)
and now print j and outside the j loop print a new line and the decrease the value of c. i leave this on u. think by how much the value of c should be decrease to get the desired output.
best of luck!

while we're on the topic of scripting languages, here's a dirty hack in python:

l = []
for i in range(1,10):
    if i % 2 != 0:
        l.append(i)
for i in range(1,6)[::-1]:
    print "".join([str(x) for x in l[0:i]])

serfurj what are you talking about that is totally irrelevant

mikeandike22,
did you read the question?

commented: whatever mikeandike22 helping out the rep +1

i'm not sure how my post is totally irrelevant. perhaps i shouldn't have said that we're on the "topic" of scripting languages, but instead that this is a thread in the c/c++ forum and i'm continuing with the off-forum-topic discussion.

anyways, that python code prints what you want. if you know python it will probably help you out when writing the php code.

commented: mikeandike22 can be a little slow sometimes... +5

I think serfurj's post is completely on-topic, as it gives the OP an idea of how it's done in another language, so they're not being spoon-fed. Sounds like an excellent answer to me...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.