Calculator Program in C using Switch Case

Calculator Program in C

Here you get the example code of Calculator Program in C using Switch Case.

Calculator definition: An electronics machine, that is used to do the arithmetical operations on the numbers is called calculator. It may be simple calculator(used for simple calculations) of scientific calculator( used for big and advanced scientific calculations).

How to make Calculator?

Here we are making a simple Calculator program in c using switch case.  In this program we will take two values a, b from the user, Then ask the user to enter a choice If he wants to perform Addition, Subtraction, Multiplication, or Division. After that, we will perform the operation choose by the user and display the result as output after execution.

Then we will perform Addition, Subtraction, Multiplication, and Division the operations according to the user’s choice the program asks the user for continuing the above process if the user enters “y” then all the above process starts again, if the user enters “n” then it will end the program.

Algorithm

Step 1: Input any two numbers.

Step 2: Display 1 for addition, 2 for subtraction, 3 for multiplication, 4 for division

Step 3: If the user inputs 1

            a. Add  the both numbers and store in c.

            b. Print the value of c.

            c. Come out of the program.

Step 4: If the user inputs 2

           a. Calculate the difference of  the both numbers and store in c.

           b. Print the value of c.

           c. Come out of the program.

Step 5: If the user inputs 3

           a. Multiply the both numbers and store in c.

           b. Print the value of c.

           c. Come out of the program.

Step 6: If the user inputs 4

          a. Divide the both numbers and store in c.

          b. Print the value of c.

          c. Come out of the program.

Step 7: Print Invalid choice.

Example of Calculator Program in C using Switch Case

Input

Enter two values : 2  5

Operations:

1.  Addition

2. Subtraction

3. Multiplication

4. Division

Enter your choice : 1

Output

Result of addition is : 7

 

 

 

Check out our other C programming Examples

 

 

 

1 thought on “Calculator Program in C using Switch Case”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top