•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,771 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,518 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1434 | Replies: 7
![]() |
•
•
Join Date: Dec 2004
Location: Utha
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
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!
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!
•
•
Join Date: May 2004
Location: Boston,MA
Posts: 1,362
Reputation:
Rep Power: 7
Solved Threads: 16
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!
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!
•
•
Join Date: Dec 2004
Location: galveston, texas
Posts: 35
Reputation:
Rep Power: 4
Solved Threads: 1
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]])•
•
Join Date: May 2004
Location: Boston,MA
Posts: 1,362
Reputation:
Rep Power: 7
Solved Threads: 16
serfurj what are you talking about that is totally irrelevant
•
•
Join Date: Dec 2004
Location: galveston, texas
Posts: 35
Reputation:
Rep Power: 4
Solved Threads: 1
•
•
Join Date: Dec 2004
Location: galveston, texas
Posts: 35
Reputation:
Rep Power: 4
Solved Threads: 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.
anyways, that python code prints what you want. if you know python it will probably help you out when writing the php code.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- learning php (PHP)
- PHP vs ASP... the big ShOwdOwN (IT Technologies and Trends)
Other Threads in the PHP Forum
- Previous Thread: I need help with a form please
- Next Thread: Access PostgreSQL from PHP



Linear Mode