Geeks Talk

Prepare for your Next Interview




Simple for loop

This is a discussion on Simple for loop within the C and C++ forums, part of the Software Development category; Hi guys, main() { int i=0, j=0,z=0; For(i=0; j,z;i++) printf("i = %d\n",i); } what does this mean????? how does the ...


Go Back   Geeks Talk > Software Development > C and C++

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 04-10-2008
Junior Member
 
Join Date: Apr 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jbmukund is on a distinguished road
Simple for loop

Hi guys,

main()
{
int i=0, j=0,z=0;
For(i=0; j,z;i++)
printf("i = %d\n",i);
}

what does this mean?????
how does the condition j,z get evaluated?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-13-2008
Junior Member
 
Join Date: Apr 2008
Location: Switzerland
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
mopodo is on a distinguished road
Re: Simple for loop

Not at all.

Your snipplet does nothing.
If you set j and z to true, you have an endless loop.

here a for how it's used normally
Code:
main() {
 int i=0;

 for(i=0;i<11;i++) {
  printf("i = %d\n",i);
 }
}
Reply With Quote
  #3 (permalink)  
Old 05-02-2008
Junior Member
 
Join Date: May 2008
Location: Bangalore
Posts: 8
Thanks: 1
Thanked 3 Times in 2 Posts
nisheedhcalicut is on a distinguished road
Re: Simple for loop

Hello,

your for loop will do nothing. bcz, it will check the value of j and if it is non zero ,it will execute the printf(). Here it is zero , so wont do anything
Reply With Quote
  #4 (permalink)  
Old 05-14-2008
Junior Member
 
Join Date: Nov 2007
Location: chennai
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
naveenark is on a distinguished road
Re: Simple for loop

Quote:
Originally Posted by jbmukund View Post
Hi guys,

main()
{
int i=0, j=0,z=0;
For(i=0; j,z;i++)
printf("i = %d\n",i);
}

what does this mean?????
how does the condition j,z get evaluated?
I have a doubt as to whether more than one condition can be tested in for loop....
Reply With Quote
  #5 (permalink)  
Old 05-14-2008
Junior Member
 
Join Date: May 2008
Location: Stockholm
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
geesree is on a distinguished road
Re: Simple for loop

yes!! you can test more than one condition in for loops
Reply With Quote
  #6 (permalink)  
Old 05-19-2008
Junior Member
 
Join Date: May 2008
Location: Bengaluru
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
mohantyrk1 is on a distinguished road
Re: Simple for loop

in for loop we can go for multiple condition.
your for loop , i.e. syntactically correct , but you'll not get any output, due to condition always 0 , means false . so won't execute next statement.
Reply With Quote
Reply

  Geeks Talk > Software Development > C and C++


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
How many times the while loop execute chandanavemulapally C and C++ 7 02-26-2008 01:02 PM
Even and odd loop deblina C and C++ 11 01-17-2008 07:34 AM
Run report without resolving loop sonies Data Warehousing 2 12-13-2007 04:00 AM
Implement FOR Loop Geek_Guest QTP 1 10-23-2007 05:26 AM
Store Value using loop in procedure talha_saeed SQL 2 10-23-2007 02:03 AM


All times are GMT -4. The time now is 09:28 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved