In any programming language there are some control structures that are used to change the flow of control as required. Two most commonly used control structure are as:
1. iterative structures
2. conditional structures
Conditional structures consist of some condition statements (like if-else statement in C++). These statements check a condition, and perform an action (e.g., execute some statements or call a function etc.) in the case of true condition an in the case of false statement they perform something else as specified by the programmer.
Iterative structures are used to iterate one or more statements either for a specified number of times or until a specified condition if fulfilled.
the most commonly used iterative structures in C++ are for loop , while loop and do while loop. these may be semantically different in different languages but generally these are same in semantics.
for loop is normally called counter loop because it is used to iterate the control for a specified number of times and while loop is called conditional loop.
The third control structures are 'got' statement which neither checks a condition nor iterates statements.
The Goto statement when encounters, just transfer the control to the specified location.
This type of structures are not commonly used today because they don't provide some sense of programming.
ไม่มีความคิดเห็น:
แสดงความคิดเห็น