Algorithm to Make a Simple Calculator
- Initialize two float variables num1 and num2 to take two operands as input.
- Initialize a char variable op to take the operator as input.
- Start the switch statement with op as the expression of the switch statement.
- Now, create cases for different arithmetic operations.
- ‘+’ for addition
- ‘-‘ for subtraction
- ‘*’ for multiplication
- ‘/’ for division
- Default case for the case when the entered operator is not one of the above operators.
- The operation will be performed based on the operator entered as the input.
C++ Program to Make a Simple Calculator
A simple calculator is a device used to perform basic arithmetic operations such as addition, subtraction, multiplication, and division. It makes arithmetic calculations easier and faster. In this article, we will learn how to code a simple calculator using C++.
Contact Us