Simple calculator

Write a function @calculator(a, b, operator)@ to compute simple arithmetic expressions. The function receives as arguments two numbers aa and bb and a character @operator@ that is always either ’+’, ’-’ or ’*’. The function has to return either the addition a+ba + b, substraction aba - b or the multiplication a*ba*b depending on the actual value of @operator@.

Sample session

Problem information

Author: ProAl

Generation: 2026-01-25T17:38:17.222Z

© Jutge.org, 2006–2026.
https://jutge.org