Nilaa Examples

Program to Display "Vanakkam, Ulagam!"

PATHIVU() is a Built in Nilaa function, it is used to print statements and variables. It is so simple to program using Nilaa, you don't have to include any external files or methods or even a ; (semi colon) at the end of each line.
The following code will print the text "Vanakkam, Ulagam!" or any other text or variables given inside the paranthesis. But keep in mind "" (quotes) needs to be used when printing strings. Give it a try here.

>> PATHIVU("Vanakkam, Ulagam!")

Output
>> Vanakkam, Ulagam!

Program to Add Two Integers

>> MARI a = 5
>> MARI b = 5
>> PATHIVU(a + b)

>> Output
>> 10

Program to Multiply Two Float points

>> MARI a = 5.75
>> MARI b = 4.20
>> PATHIVU(a * b)

>> Output
>> 24.150000000000002

Program to Find the Largest Number Among Three Numbers

>> MARI n1 = 50
>> MARI n2 = 51
>> MARI n3 = 49

>> ENDRAL n1 >= n2 MATRUM n1 >= n3 ENIL
>> PATHIVU("n1 is the largest number.")
>> VERUENDRAL n2 >= n1 MATRUM n2 >= n3 ENIL
>> PATHIVU("n2 is the largest number.")
>> VERU
>> PATHIVU("n3 is the largest number.")
>> MUDI

>> Output
>> n2 is the largest number.

Program to Check Whether a Number is Positive or Negative

>> MARI num = 5
>> ENDRAL num <= 0.0 ENIL
>> ENDRAL num == 0.0 ENIL
>> PATHIVU("You entered 0.");
>> VERU
>> PATHIVU("You entered a negative number.");
>> MUDI
>> VERU
>> PATHIVU("You entered a positive number.");
>> MUDI

>> Output
>> You entered a positive number.

Program to Find the Sum of Natural Numbers using Recursion

>> SEYAL addNumbers(n)
>> ENDRAL n != 0 ENIL
>> THIRUMBU n + addNumbers(n-1)
>> VERU
>> THIRUMBU n
>> MUDI
>> MUDI
>> MARI num = 20
>> addNumbers(num)

>> Output
>> [, 20, 210]

Program to Concatenate Two Strings

>> MARI name = "this string is "
>> MARI age = "concatenated!"
>> PATHIVU(name + age)

>> Output
>> this string is concatenated!