question 6 ece

mail@pastecode.io avatar
unknown
plain_text
2 years ago
441 B
2
Indexable
Never
function result = basic_calc(x, y, operation)
switch operation
    case "addition"
        result = x+y;
    case "subtraction"
        result = x-y;
    case "multiplication"
        result = x*y;
    case "division"
        result = x/y;
    case "exponentiation"
        result = x^y;
    otherwise 
        disp("given operation cannot be found. try again with addition, subtraction, multiplication, division or exponentiation.")
end
end