To compare values, we need operators. Boolean type plays an important role here.

Let’s use two previously defined integer variables containing integers 3 and 5

bool bResult = false

bResult  =  iFirstNumber < iSecondNumber

print bResult  

This code will output “true” because 3 is indeed less than 5, and  operator “<“ returned value true as a result of the comparison between these two variables.

Assigning a value of bResult = falseat the beginning of the code is called initialization of the variable and it is the recommended thing to do because the program could crash or misbehave if it attempts to use a variable that is not assigned any value.

Variable can be initialized during its declaration like this: 

bool bResult = false 

or in a separate line right after the initialization:

bool bResult

bResult = false

Next page ->

Leave a comment

Your email address will not be published. Required fields are marked *