Create and use some variables in Octagon. Do some maths on some variables and display the results.
The result of the program running should be:
Done exiting now! Result of subtracting is : 10 100 1.50 is -91.50 Result of adding 10 100 -3.14 is 106.86 Variables Example Program no 1
Program
---
Variables Program Example
Create and use some variables in Octagon
---
prog_vars =
d/a 10 -- integer var set to 10
d/b 100 -- integer var set to 100
d/c -3.141 -- float var set to -3.141
d/total 0.0 -- float to hold total
d/message "" -- text var, empty
prog_vars.
prog_start =
/total 0.0 -- reset /total to 0.0
prog_start.
prog_loop =
print "Variables Example Program no 1"
-- Add some numbers , store result in /total
add /a /b /c -> /total
-- Set a message to show
/message "Result of adding "
-- Show the result
print "/message /a /b /c is /total"
-- Set new value of /c
/c 1.5
-- Subtract some numbers , store result in /total
sub /a /b /c -> /total
-- Update the /message
/message "Result of subtracting is : "
-- Show the result
print "/message /a /b /c is /total"
print "Done exiting now!"
exitprog
prog_loop.
prog_stop =
exitprog
prog_stop.