Q10. Write a code to make a simple calculator

Calculator :- A calculator is used to make mathematical calculations. In this program we will create a simple calculator that can perform an arithmetic operation (+, -, *, /)
For Example :-
Enter an operator (+, -, *, /): +
Enter two operands: 4, 5
4 + 5 = 9
So as we can see that first we have to choose which arithmetic operation we want to do, then after selecting two operands for which we have to do arithmetic calculation.

There is Following Algorithm For simple calculator

START
Step 1 : Initialize the two numbers.
Step 2 : Ask the user to enter an option by giving four options.
Step 3 : After getting the option from the user write if conditions for every operation based on the option.
Step 4 : Perform the respective operation.
Step 5 : Print the result.
STOP

There is Following code to swap two numbers without using third variable

Output

Enter an operator (+, -, *, /): +
Enter two operands: 4,5
4+5=9

Recommended Programs
Program to find factorial of a number
Program to count number of digits in a number