Monday, May 24, 2010

"Break" in this C++ programming?

Can anyone tell me what "Break" is used here in this C++ sentence? Anyone who answer 1st will get 10 points!





#include %26lt;stdio.h%26gt;


#include %26lt;conio.h%26gt;





int main(void)


{





for(; ;)


{





if (getche() == 'a')


{


auto int t;





for (t=0; t%26lt;'a'; t++)


printf("%d ", t);





break;


}





}





return 0;





}

"Break" in this C++ programming?
Break is used within loops and switch statements to jump to the end of the code block. It causes the "//code..." above to be skipped and terminates the loop. In switch case statements, break causes the remaining cases to be skipped--it prevents "falling through" to other cases.
Reply:It terminates the outer for loop " for(;;) ", which has no explicit termination condition.
Reply:here you want to print t - a no of times;


break is used to come out of if loop once the second for loop


has run its course.





if you dont use break , then for the first or loop


which is having no arguments or parameters


-it can end in infinite loop.

sp

No comments:

Post a Comment