Arithmetic operations using switch case and do while loop in C Programming

A switch case is used to select one among multiple options.

Can we use arithmetic operators in switch case:

Yes, We Can use we. To provide symbols in a case statement a single quote is used.

To perform arithmetic operations, we create a case for each operator, for the matching operator, it will call the appropriate case statements and execute the statements.

In our program, we will use a switch case statement and do while loop statement

You can check both details here

  1. Switch Case Statement
  2. Do While Loop Statement

algorithm for arithmetic operations using switch case in c

Lets see steps to write this C program

  1. Declare variables
  2. start loop
  3. get num1 ,operator, num2 value from user
  4. start switch case and pass operator in switch case
  5. write the case for arithmetic operators and their associated statements
  6. define default in switch case
  7. Take input from the user to check loop continuity
  8. if the user enters yes then repeat steps 2-7 else end the loop.
Arithmetic Operations Using Switch Case in C Programming
Fig: Arithmetic Operations Using Switch Case in C Programming

C program for arithmetic operations using switch case

Output

Read More

  1. C++ program for student details
  2. Anonymous Object in C++
  3. Lowercase character to uppercase character
  4. Command Line Argument
  5. Local vs Global Object in C++
  6. Local and Nested Classes in C++
  7. Switch Case in C Programming
  8. Constructor in C++
  9. Know more about C++