We already saw that a program executes one command after another, from top to bottom. But usually we need some branching/decisions to make while executing a program. Let's write a program that will print if a number is positive or negative:

For example, if the user enters number 9, output should be "Positive". If user enters number -55, output should be "Negative".

Maybe you haven't thought about it, but expression x > 0 has type Boolean. Boolean can be true or false.

Congratulations! You've come to the end of Basic tutorial. Hope you have learned something useful! :) You can continue learning with Intermediate level tutorials.

CodeExploreLearnLog In