if statement
In the previous section i have given only the introduction of conditional statements. Let us discuss them in detail.
If statement
When an if condition is true then the statements in if section are executed. Otherwise the statements which are outside of an if section will be executed.
The syntax of if statement is as follows:
Ex 1 A sample example of if statement
Output
Welcome
To VMS |
Ex 2 The above program can also be written as follows
Output
Welcome
To VMS |
Ex 3 Another example of if statement is shown in below
Output
VMS |
Ex 4 The above program can also be written as follows
Output
VMS |
if statement examples without Boolean variables
Ex 1: An example program of if without Boolean variables
Output
35
HelloWorld |
Ex 2 Another example program of if without Boolean variables
Output
nothing is greater than z
x is lower |