Congratulations! If you made it this far, you’ve successfully created a four-function calculator. Now, try to implement some more functions.

For example, create a sqrt() function that takes one number and output its square root. Specifically, you should be able to compute the square root of a number by first entering the number, then pressing the sqrt() button, and finally pressing the equals button.

Also try adding more single-operand functions (functions that take one number as the input) like a square function or a cube function.

Based on how your current calculator stores operands, you’ll discover that single-operand functions are trickier to implement than you might think. Beware.

Previous