How to create an calculator using 1 line?

0 votes
asked Feb 6 by carl

2 Answers

0 votes
answered Feb 6 by anonymous
cal = op == '+' ? (a + b) : (op == '-' ? (a -b): (op == '*' ? (a*b): ( op == '/' ? (a / b): NAN ) ) );
0 votes
answered Feb 6 by (140 points)
not sure it can be done in one line
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...