Answers for "how to convert character into operator"

0

how to convert character into operator

int Compute(char c, int a, int b)
{
    switch (c) {  
    case '+': return a+b;
    case '-': return a-b;
    case '*': return a*b;
    case '/': return a/b;
    default: throw std::runtime_error("No such operator");
    }
}
Posted by: Guest on May-25-2021

Code answers related to "how to convert character into operator"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language