You can build a simple calculator with C using switch cases or if-else statements. This calculator takes two operands and an arithmetic operator (+, -, *, /) from the user, however, you can expand the program to accept more than two operands and one operator by adding logic. Then, based on the operator entered by the user, it conducts the computation on the two operands. The input, however, must be in the format “number1 operator1 number2” (i.e. 2+4).
You can build a simple calculator with C using switch cases or if-else statements. This calculator takes two operands and an arithmetic operator (+, -, *, /) from the user, however, you can expand the program to accept more than two operands and one operator by adding logic. Then, based on the operator entered by the user, it conducts the computation on the two operands. The input, however, must be in the format “number1 operator1 number2” (i.e. 2+4).