Exforsys

Online Training

What is the Output

This is a discussion on What is the Output within the C and C++ forums, part of the Programming Talk category; What will happen when a semicolon ; is placed at the end of for statement as below: for(i = x; i &...


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

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-26-2007, 04:40 PM
Senior Member
 
Join Date: Apr 2006
Posts: 141
Adrian is on a distinguished road
Exclamation What is the Output

What will happen when a semicolon ; is placed at the end of for statement as below:
for(i = x; i < a; i++);
Will the above statement give error? If not what will be the outcome?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-26-2007, 11:50 PM
Member
 
Join Date: May 2006
Posts: 38
zsk_00 is on a distinguished road
nothing happens! Your code runs slower.
used it to put delay in the processing, then the processors became much faster and had to find other ways.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-30-2007, 02:47 AM
Junior Member
 
Join Date: Mar 2007
Posts: 3
vamsy_569 is on a distinguished road
the above statement wont give any error but
semicolon is a null statement.semicolon gets executed till condition satisfies
once the condition wont satisfy control comes out of for loop and the block
of for loop gets executed(only once).

if semicolon is placed where ever it is necessary it acts as a statement terminator otherwise it acts as a null statement.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-31-2007, 03:51 AM
Junior Member
 
Join Date: Mar 2007
Posts: 1
raj48_v is on a distinguished road
Quote:
Originally Posted by Adrian View Post
What will happen when a semicolon ; is placed at the end of for statement as below:
for(i = x; i < a; i++);
Will the above statement give error? If not what will be the outcome?
no error will be displayed it will repeat until i becomes less than a.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-02-2007, 05:32 AM
Junior Member
 
Join Date: Apr 2007
Posts: 1
sidsin is on a distinguished road
Correct and will run till i<a is satisfied.
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
Control Output caradoc DB2 3 04-09-2007 08:59 AM
To achieve Output Ralph Linux 0 12-12-2006 03:58 AM
C Programming - Managing Input and Output Operations JobHelper Career Advice 0 04-15-2006 08:30 AM
Controlling PHP Output: Caching and compressing dynamic pages techguru Unix Articles and Tutorials 0 08-28-2005 11:26 AM
[gnu.bash.bug] BASH Frequently-Asked Questions (FAQ version 3.26) Chet Ramey Tech FAQ 0 05-27-2004 11:00 AM


All times are GMT -4. The time now is 12:16 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.