Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

#1
January 12th, 2013, 03:06 AM
 Viky
Registered User

Join Date: Jan 2013
Posts: 2
Time spent in forums: 14 m 43 sec
Reputation Power: 0
For loop

what does this do..?

Q1? for(;;);
Q2? for(p(a);p(b);p(c););

#2
January 12th, 2013, 11:55 AM
 WaltP
Registered User

Join Date: Feb 2004
Posts: 19
Time spent in forums: 2 h 26 m 27 sec
Reputation Power: 0
Quote:
 Originally Posted by Viky what does this do..? Q1? for(;; Q2? for(p(a);p(b);p(c);

Q1: endless loop.

Q2: How about you try describing what you think it does and we'll correct you. That's ultimately a better way to learn.
clifford disagrees: Well done Walt - you did somone's homework for them! That's not normally how it works around here -
the last thing we need is graduates knowing nothing except how to cheat.

#3
January 13th, 2013, 03:30 AM
 clifford
Contributing User

Join Date: Aug 2003
Location: UK
Posts: 4,824
Time spent in forums: 1 Month 2 Days 21 h 1 m
Reputation Power: 1800
Quote:
 clifford disagrees: Well done Walt - you did somone's homework for them! That's not normally how it works around here - the last thing we need is graduates knowing nothing except how to cheat.
My apologies Walt; somewhat unfair - you only answered the first question. I did not however down-rep you in my response if that is any consolation.

Last edited by clifford : January 13th, 2013 at 03:40 AM.

#4
January 13th, 2013, 03:37 AM
 clifford
Contributing User

Join Date: Aug 2003
Location: UK
Posts: 4,824
Time spent in forums: 1 Month 2 Days 21 h 1 m
Reputation Power: 1800
A for statement comprises four parts:
1. 1 Initial expression,
2. 2 loop condition expression,
3. 3 loop body
4. 4 iteration expression
And operates thus:

do 1 then while 2 do 3 then 4

Any of 1,2,3 or 4 may be empty (or null) statements. A null statement is just a semi-colon on its own.

An expression is implicitly "true" is it is non-zero.

That is all you need to know to work out the answer to both.

 Viewing: Dev Shed Forums > Programming Languages > C Programming > For loop