Exforsys

Online Training

Reason for Output

This is a discussion on Reason for Output within the C and C++ forums, part of the Programming Talk category; I have a C program as for(i=1;0;i++) { printf("Hello"); } I thought there would be ...


Go Back   Exforsys > Programming Talk > C and C++

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-25-2006, 11:08 PM
Senior Member
 
Join Date: Apr 2006
Posts: 153
cyrus is on a distinguished road
Reason for Output

I have a C program as
for(i=1;0;i++)
{
printf("Hello");
}

I thought there would be no output but I found in the book I studied the answer given as Hello printed once. Is this a printing error or can anyone explain the reason for the same.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-14-2007, 11:02 AM
Member
 
Join Date: Apr 2006
Posts: 98
Angela is on a distinguished road
The reason is the for loop gets executed once and the next time when it gets incremented only the condition fails. So Hello is printed once.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Kindly provide the Reason Angela Oracle Database 2 12-28-2006 03:48 PM
Reason for the Choice of Operating System Angela Linux 0 12-12-2006 04:19 AM
Need Technical reason priyaraji Coldfusion 0 12-07-2006 01:46 AM


All times are GMT -4. The time now is 06:00 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.