![]() |
| Pythagorean theorem in Cue Editor |
In the gray box, titled "Events", you can see the source code on the left an and debug output and trace on the right. Output is like a console, but here is nothing to print out. In Trace you can see what commands in what order (and with what result) has been executed.
"RESULT" is the value, what is returned into code after processing the Cue code.
In the code I defined two constants, but you can get those input values from QetriX, or e.g. GET, POST or COOKIE variables. So first two lines contains numbers 3 and 4. Pythagorean theorem for calculation the hypotenuse (variable "c") is: "c = sqrt(a² + b²)", so first of all we have to calculate square power for "a" and "b" (lines 3 and 4, showing two different ways how to achieve that, using "mul" and "pow" commands). Then we add those two results together and finally we calculate a square root of the sum.
There are no gotos or decisions, so the code is nicely straight - from Start ("S" circle) to End ("E" circle). Final result of the code is the same, as the result of the last line.

No comments:
Post a Comment