This chapter discusses the basics of control structure of C++ language.
The C++ control structure covers certain operations that are performed repetitively called as loop statements.
C/C++ has four statements that perform an unconditional control transfer. These are return, goto, and break and continue. Of these, return is used only in functions. goto and return may be used anywhere in the program but continue and break statements may be used only in conjunction with a loop statement.
The for loop comprises three actions. The three actions are placed in the for statement itself. The three actions initialize counter, test condition and re-evaluation parameters are included in one statement. The for statement is equivalent to the while and do-while statements. The only difference between for and while is that the latter checks the logical condition and then executes the body of the loop, whereas the for statement test is always performed at the beginning of the loop. The body of the loop may not be executed at all times if the condition fails at the beginning. The do-while loop executes the body of the loop at least once regardless of the logical condition.
Test Your Skills
Test Your Skills Now!
This is only a practice test, it is designed to help you revise your concepts
The test contains questions, only 1 option is correct for each question
This is a timed test.
After you have finished the test, press on the 'Finish Test' button to know your score and get the correct answers