Conteúdo principal

Programming logic - Decision Commands - If / Then / Else

 

Conditional branches are the commands that the developer programs to make the machines make a logical decision.

On this page I will explain the If / Then / Else conditional branch.

I'll leave here the explanations about the other conditional deviation: Switch.

 

If / Then / Else

This conditional structure is used in comparisons. If it meets a condition, it forwards to one place or result, if not, forwards to another. See the diagram below. In it we are going to make an algorithm to enter the information about the temperature. If the temperature is higher than 20, the answer will be "Today is hot", otherwise it will answer "Today is cold"

 

Flowchart of the logic of these conditional diversion


This example shows this conditional branchl

 
 
    Algortimo 1:



Result:
No results. Enter the temperature
Section: