Control Flow In Real World Programming

Introduction

The Control Flow is the request where the PC executes proclamations in content. Code is run all together from the primary line in the record to the last line, except if the PC stumbles into the (very successive) structures that change the control stream, for example, conditionals and loops. It allows our program to make decisions about what code is executed and when.

Example

Let's see a real world scenario where two friends met in a public place and have a random conversation about lunch plans. Here is the plan that they want to execute and below are the permutations and combinations which I have explained in the flow diagram.

Basically, control flow has two types of statements.

  1. Conditional Statements
  2. Looping statements 

Conditional Statements

Conditional statements fundamentally verify whether the specific condition is true or false. It's pretty simple, when we are dealing with real world problems in the events if the condition is valid then we are going to execute one piece of code if not other.

Types of Conditional Statements 

  1. IF Statements
  2. Switch Case Statements
  3. Ternary 

Looping Statements

A loop is utilized for executing a block of statements more than once until a specific condition is fulfilled. For instance, when you are showing numbers from 1 to 100 you might need to set the worth of a variable to 1 and show it multiple times, expanding its worth by 1 on each loop iteration.

Types of Looping Statements

  1. For loop
  2. While Loop
  3. Do

Conclusion

Thank you for reading, I hope this article gives you brief idea about the control flow in the computer programming and types of statements involved in it.

Please let me know your questions, thoughts, or feedback in the comments section. I appreciate your feedback and encouragement.

Keep learning ...!