Control Flow in C language – if, while, for and many more

Control Flow in C language – if, while, for and many more

In any programming language, you will often need to make decisions. This will take the program into different functions depending on the answer of a question, result or evidence. This is called Control Flow and it is a collection of powerful instructions for decision making. Without them, electronic devices couldn't be able to make decisions upon evidence.

What is Control Flow?

You might be asking yourself: what is the evidence? It is called binary values because they can only be either 1 or 0 and they are the result of a question, like:

  • Is result A higher than result B?
  • Is result B equal to 100?
  • Is result A true?

If the answer is affirmative or 1, the code will execute a piece of code; if it is negative or 0, the code will execute another piece of code.

Types of Control Flow

There are different kinds of Control Flow instructions.

  • one selection: if(if-else).
  • multiple selection: switch.
  • loops: while, do, for.
  • jumps: break, continue.

I'm going to place here the Control Flow instructions in different sections as I compose them.

Examples of Control Flow

if

One of the most basic functions available is ‘if‘. A simple question where the answer is either true (1) or false (0); depending on the answer, a certain code will be executed. Click in the link below to read about it.

switch

For repetitive decision making, there is Switch. Excellent for programming and to leave the clutter behind. Click in the link below to read about it.

while

For repetitive tasks which require a sequence, ‘while‘ is frequently used. Click in the link below to read about it.

do

Coming soon!

for

Coming soon!

break

Coming soon!

continue

Coming soon!

techZorro's Index of Content

Keep Reading!

You have reached this far!

Thank you for reading the blog post. Your comments and suggestions are welcomed. At the bottom of this page, leave a message or just say hi! The whole team of techZorro will appreciate it. Don't forget to share it on social media as well.

techZorro’s Index of Content

Click on the following link to browse likewise content in the blog in techZorro. This index will help you see what you are looking for in a bird’s eye view.

techZorro's Newsletter!

If you enjoyed this blog post, please subscribe to techZorro’s newsletter so you don’t miss any future blog posts!

2 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.