c++ calculator program using switch case

#include<iostream>
using namespace std;
int calculator(int num1,int num2,int num3);
int main()
{
    //int num1,num2,num3,choice;
    int a,b,c,choice;
    cout<<"enter the first number"<<endl;
    cin>>a;
    cout<<"enter the second number"<<endl;
    cin>>b;
    cout<<"************************"<<endl;
    cout<<"****Make your choice****"<<endl;
    cout<<"1.Addition"<<endl;
    cout<<"2.Subtraction"<<endl;
    cout<<"3.Multiplication"<<endl;
    cout<<"4.Division"<<endl;
    cout<<"************************"<<endl;

    choice=calculator(a,b,c);
    return 0;
}
int calculator(int num1,int num2,int num3)
{

    int choice;
    cin>>choice;
    switch(choice)
    {

        case 1: cout<<"you have selected Addition"<<endl;
                num3=num1+num2;
                cout<<"Addition of two numbers is "<<num3<<endl;
                break;

        case 2: cout<<"you have selected Subtraction"<<endl;
                num3=num1-num2;
                cout<<"Subtraction of two numbers is "<<num3<<endl;
                break;

        case 3: cout<<"you have selected Multiplication"<<endl;
                num3=num1*num2;
                cout<<"Multiplication of two numbers is "<<num3<<endl;
                break;

        case 4: cout<<"You have selected Division"<<endl;
                num3=num1/num2;
                cout<<"Division of two numbers is "<<num3<<endl;
                break;

        default: cout<<"You have entered wrong choice"<<endl;
                    break;
    }
}


Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
calculator using switch case in c++ gfg calculator program in c++ using functions and switch case scientific calculator program in c++ using switch case switch case calculator in cpp making a calculator with switch in c++ how to write a simple calculator program using switch case c++ switch case with c++, when using calculator c++ calculator using switch case syntax of switch statement c++ calculator function syntax of switch statement c++ calculator calculator using switch case in c++ c++ simple calculator using switch case using the switch statement in c++ to make calculator calculator in c++ using switch write a program to make a calculator using switch case in c++ c++ basic arthimatic calculator code for a calculator in c++ calculator in c++ write a program that mimics a calculator c++ make calculator in C++ to find add,sub and power make calculator in c++ c++ calculator double division simple calculater code c++ how to add a number string to a number in cpp in simple calculator calculator program in c++ using switch case calculator program using switch case in cpp output calculator c++ CALCULATOR USING SWITCH C++ calculator c++ programm calculator using only ++ calc c++ simple basic calculator c++ source code for calculator in c++ how to write a simple calculator program in cpp basic cpp calculator Write a simple calculator program that calculates the difference, sum or product of two numbers. calculation in c++ c++ % calculation c language program for simple calculator enter 1 for addition enter 2 for subtraction calculator using in cpp calculator using switch case in cpp Write a C++ program that performs calculator operations and throws exception if an attempt is made to divide a number by zero or if an invalid operator is applied (10marks) Operations allowed- +, -, *, / how to make calculator using c++ calculator c__ calculator.c++ c++ program calculator how to implement calculator c++ C plus plus cal test write a program to make simple calculator using if else in c++ write a program to make simple calculator using switch case in c++ c++ calculator code creating a calculator in c++ calculator using switch and class c++ simple calculator c++ how to create calculator in c++ 2 digitcalculater cpp progrram calculator program in c++ basic calculator c++ c++ how to make a calculator calcuator program using siwtch case c++ cpp code for calculator how to write a calculate in c++ simple calculator program in c++ how to build a calculator in c++ how to make a c++ calculator with all operations c++ calculator how to implement division calculator in cpp c++ calculator program without using switch case c++ switch case calculator simple calculator c++ void main simple calculator codezen c++ turbo c++ calculator source code c++ calculator using functions void main c++ calculator with fuctions c++ program to make a simple calculator using functions c++ program to make a simple calculator complete this simple calculator program using functions c++ c++ calculator function calculator program in cpp c++ calculator project c++ calculator c++ calculator program how to make a calculator in c++ making a calculator in c++ Design calculator c++ calculator in cpp using switch calculator c++ c++ calculator program using switch case
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source