CONTROL STRUCTURE in C++:-
A control structure is a block of programming that analyzes variables and determines the order in which statements are executed.
Loop Control Structure:-
For(initialize counter; test condition; re-evaluation parameter)
Body of loop
Selection Control Structure:-
Case constant A;
Case constant B;
Decision Control Structure:-
Jump Control Structure:-
Some tips on Control Structure:-
If statement is used for checking range and yes/no problem
else is the optional part of the if
Execution of switch case starts from the match case.
Use break to prevent the falling of control from one case to another case.
If none of the cases are satisfied then default case will be satisfied.
Case character only can be integral constant.
Switch case only checks integral does not check the float.
Continue cannot be the part of the switch case.
Switch without case no use ( no output no error).
Switch case is the replacement of if…else statement.
Switch case is used for selection control statement.
Loop counter can be int, char and float.
If loop counter is not initialized in a loop , that is called odd loop.
Loop is an alternate of function recursion and function recursion is an alternate of loop.
For loop is suitable for finite loop , while loop is suitable for unknown loop and do while loop is suitable for at least once.
Loop counter has its own block scoping.
Drop all the parts of for loop is an infinite loop but drops all part of while and do while loop is an error.
break in loop transfer control outside the loop.
Continue transfer the control to beginning of loop.
If loop counter exceeds its range , it will be infinite loop.
Every loop has start value, step value and stop value.
If loop loses its step value , it will be an infinite loop.
Repeating some parts of program and Software delay use loop.
Loop is faster than function recursion.
Also Read:- Datatype in C++