how to convert character into operator

Solutions on MaxInterview for how to convert character into operator by the best coders in the world

showing results for - "how to convert character into operator"
Juan Diego
12 Sep 2018
1int Compute(char c, int a, int b)
2{
3    switch (c) {  
4    case '+': return a+b;
5    case '-': return a-b;
6    case '*': return a*b;
7    case '/': return a/b;
8    default: throw std::runtime_error("No such operator");
9    }
10}
11
similar questions
queries leading to this page
how to convert character into operator