The decision structure or mostly commonly known as a selection structure, is case where in the algorithm, one has to make a choice of two alternatives by making decision depending on a given condition.
Selection structures are also called case selection structures when there are two or more alternatives to choose from. This structure can be illustrated in a flowchart as follows:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirllQLX6GidVcRBJu7pYYo9LGduumR5ZlGkoqN0I3P0_XoEdqpgCfuNJSkJwr0yt4BDH0s9sLEx0LmS5Zl13FZP3HTMuX78CNvXnvTVzC9vkYghjj6-tubfEmcp4Jro-4WOGng8LZR-7Tj/s1600/code+example+2.jpg)
If condition is true
Then do task A
else
Do Task-B
In this example, the condition is evaluated, if the condition is true Task-A is evaluated and if it is false, then Task-B is executed. A variation of the construct of the above figure is shown below.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhx3Onrnxz6CyLccXA3h97OwH8blVJRg2d24Phyn7k6ZAza0jlXGyCFq0piAe4lSQilLOlDs0h-AL5iPdcTg0_FcKw01aIg5a7OT-GncwEcXBKSRcWigd1cIWwy7roi3VbBOxoPD_OUj1Z/s1600/code+example+3.jpg)
If condition is true then
Do Task-A
In this case, if condition is false, nothing happens. Otherwise Task-A is executed.
The selection requires the following.
• Choose alternative actions as a result of testing a logical condition
• Produce code to test a sequence of logical tests