Discussion :: Control Instructions - Point Out Errors (Q.No.1)
|Hemanth said: (Jul 23, 2011)|
|The 1 is printed and if condition it breaks. How it prints 1 to 10? plzzz anyone.|
|Rupinderjit Singh said: (Oct 4, 2011)|
|Condition only breaks if i>10?|
|Raju Royal said: (Feb 25, 2012)|
|for(;;) - statement will genereate infinite loop.
to terminate this infinate loop we have to use break;
but break; statement gets executed only when if(i>10) is satisfied.
So the for(;;) loop iterates for the values 1,2,...9,10.
but when i increments to 11, if(i>10) is satisfied and break; terminates the for(;;) loop :)
|Manjunath K said: (Aug 12, 2014)|
|Why it will print the 1 initially can anyone please explain ?|
|Shyam said: (Oct 31, 2014)|
|i++ means it performs post increment, means first it will assign initial value of i i.e., i = 1 and then it will increment i.|
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.