7 Replies - 4814 Views - Last Post: 02 September 2001 - 10:14 AM Rate Topic: -----

#1 cowboyraj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 31-July 01

for loop confusion

Posted 09 August 2001 - 12:10 AM

I have got some confusion in loops,just look at this code

while(0)
{
printf("Confusion");
}
the above code does not print the statement at all,since the
condition is false.ok now

for(;0;)
{
printf("Confusion");
}

the above code is similar to the above while loop,but this
code print's the statement once,when this condition is also false,why it is printing once.This code was run on Turbo C 3.0 .
Can any one explain me this
Thank u.



Is This A Good Question/Topic? 0
  • +

Replies To: for loop confusion

#2 runtime error  Icon User is offline

  • Lucky.Code
  • member icon

Reputation: 3
  • View blog
  • Posts: 629
  • Joined: 19-March 01

Re: for loop confusion

Posted 09 August 2001 - 04:31 AM

ummm im sorry can you take off those smileys and then i might be able to help.

You so that by clicking the little check box underneath the message you are typing. ;)

Was This Post Helpful? 0
  • +
  • -

#3 malkiri  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 364
  • Joined: 29-March 01

Re: for loop confusion

Posted 09 August 2001 - 07:38 AM

I wish I could tell you why...you're right; it shouldn't be printing the second "Confusion". The only thing I could conceive of is that it's your compiler, but I don't know anything about Turbo C, so I can't say for certain. If it is the compiler...that's a huge mistake!
Was This Post Helpful? 0
  • +
  • -

#4 Fowen1121  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 02-May 01

Re: for loop confusion

Posted 11 August 2001 - 05:16 PM

Turbo C or Turbo C++?
Was This Post Helpful? 0
  • +
  • -

#5 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4503
  • View blog
  • Posts: 28,411
  • Joined: 21-March 01

Re: for loop confusion

Posted 11 August 2001 - 05:18 PM

i believe turbo C.
Was This Post Helpful? 0
  • +
  • -

#6 cowboyraj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 31-July 01

Re: for loop confusion

Posted 30 August 2001 - 01:00 AM

It is in Turbo C++
Was This Post Helpful? 0
  • +
  • -

#7 deadmoon  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-April 01

Re: for loop confusion

Posted 02 September 2001 - 04:06 AM

Well does it make a big difference if it is C++ in stead of C?
Was This Post Helpful? 0
  • +
  • -

#8 runtime error  Icon User is offline

  • Lucky.Code
  • member icon

Reputation: 3
  • View blog
  • Posts: 629
  • Joined: 19-March 01

Re: for loop confusion

Posted 02 September 2001 - 10:14 AM

Quote

Quote: from deadmoon on 6:06 am on Sep. 2, 2001
Well does it make a big difference if it is C++ in stead of C?

No not really. C++ can handle c code. And the for loop is treated the same in both C and C++.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1