Introduction to Control Structures in C++

Introduction to Control Structures in C++
Di Posting Oleh : Simple Learning
Kategori : do. while else for if Loops statements

Control Structures
"Statements used to control the flow of execution in a program".


  • Means a statement through which we control the behavior of our program like what kind of
  • function it will perform, when it will terminate or continue under certain circumstances or conditions.
  • These instructions enable us to group individual instructions into a single logical unit with one entry point and one exit point. To make it more clearer, suppose we have lot of statements in our program by using control structure we control their working like either all statements will evaluate at once on the basis of certain condition or will evaluate one by one or will not be evaluated.

All programs use control structures to implement the program logic.
There are three types of Control Structures
1. Sequence
2. Selection
3. Loops/ Repetition/ Iteration
 Sequence structure in C++:
As name refers instructions  are executed in the sequence in which they are written in the program.
Example: Compound Statement:
              {
                    Statements
                    Statements - 1
                    Statements - 2
                    - - - - - - - - -
                }
 Selection structure in C++:
A structure which select which statement or block of statements will execute on the basis of our
programming logic.
Examples:
1. if - else statement
2.  switch
Loops in C++:
These structures are used to repeat the statement or set of statements.
Examples:
1. for - loop
2. while - loop
3. do - while loop

0 Response to "Introduction to Control Structures in C++"

Post a Comment