C++ Control Structures | Conditonal & Loops

In this tutorial we are going to study the different types of control structures in C++ programming language.

In a very simple case, a typical C++ program executes in a linear way starting its execution from the first statement in the main() function to the last. However, that is not the case in every program. Some programs do not execute in a linear way as there are requirements like decision making and interations in the program. For e.g. you may have to write a program to decide whether a number entered from the user is even or odd and depending on the result the tasks to be performed would be different. In that scenario you have 2 different paths to follow after the even/odd result which is a type of branching and not exactly linear. Similarly you might want to iterate a number of statements n number of times till a certain condition is satisfied hence again this is not a linear way but a iterative mechanism.

Both these types are supported in C++ programming and they are known as Control Structures or Control Statements and they enable us to make decisions and iterations possible. Basically this enhances the overall functional properties of any general purpose programming language as you can make complex decisions and perform tasks multiple times in a efficient way.

Following are the different types of Control Structures / Statements in C++ Programming –

  1. Simple Control Structures
    1. Conditional Control Structures (aka decision making statements)
      1. If – Else Statements
      2. Swtich Case Statments
    2. Looping / Iterative Control Structures
      1. For Loop
      2. While Loop
      3. doWhile Loop
  2. Functions

control structures in c++

Apart from these we have certain Jump Statements in C++ which assist in manipulating the flow of the program execution. Following are those statements –

  • The break statement
  • The continue statement
  • The goto statement

We will see the individual working and program example of each control structure in further video tutorial as this is just a theoretical overview on the topic of control structures and its types.

YouTube Video Tutorial Link on Variables & Data Types in C++

 

Leave a Reply

Your email address will not be published. Required fields are marked *