Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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");
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #character #operator
ADD COMMENT
Topic
Name
7+1 =