While Loop

'while' is a looping attribute which is used to perform a set of instructions until a given condition is satisfied.

SRON provides 'while' attribute to work on while loop. To provide a condition, 'condition' attribute is used.

Syntax of 'condition':

condition :  conditional_value

Examples:

Correct Syntax:
    condition : false
or
    condition : true
or
    condition : ${ val != 10 }

---------------------

Wrong Syntax:
    condition : ()
or
    condition : (true)
or
    condition : ([1,2,3,4,5])

'condition' attribute requires a 'Bool' type value, if a 'Bool' type value is not found, then error/exception will be thrown.


Sample Code to print 0 to 5 numbers.

OUTPUT :

0 1 2 3 4 5


Sample Code to print even number between 0 and 15.

OUTPUT :

2 4 6 8 10 12 14


Last updated