Exforsys
+ Reply to Thread
Results 1 to 5 of 5

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; ...

  1. #1
    Adrian is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    124

    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?


  2. #2
    zsk_00 is offline Member Array
    Join Date
    May 2006
    Answers
    38
    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.


  3. #3
    vamsy_569 is offline Junior Member Array
    Join Date
    Mar 2007
    Answers
    3
    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.


  4. #4
    raj48_v is offline Junior Member Array
    Join Date
    Mar 2007
    Answers
    1
    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.


  5. #5
    sidsin is offline Junior Member Array
    Join Date
    Apr 2007
    Answers
    1
    Correct and will run till i<a is satisfied.


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...