Skip to main content
Engineering LibreTexts

6.1: Conditional Execution

  • Page ID
    29056
  • Decision Making in C++

    There come situations in real life when we need to make some decisions and based on these decisions, we decide what should we do next. Similar situations arise in programming also where we need to make some decisions and based on these decisions we will execute the next block of code. For example, in C++ if x occurs then execute y else execute z. There can also be multiple conditions like in C++ if x occurs then execute p, else if condition y occurs execute q, else execute r. This condition of C else-if is one of the many ways of importing multiple conditions.

    Decision making statements in programming languages decides the direction of flow of program execution. Decision making statements available in C or C++ are:

    1. if statement
    2. if..else statements
    3. nested if statements
    4. if-else-if ladder
    5. switch statements
    6. Jump Statements:
      1. break
      2. continue
      3. goto
      4. return

    We will take a look at all of these possibilities.

    Adapted from: 
    "Decision Making in C / C++ (if , if..else, Nested if, if-else-if )" by Harsh AgarwalGeeks for Geeks is licensed under CC BY-SA 4.0