c++ calculator program using switch case
C++
#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;
}
}
Also in C++:
- Title
- variabili in c++
- Category
- C++
- Title
- queue stl c++
- Category
- C++
- Title
- How to read a file in in C++
- Category
- C++
- Title
- appending a double to a string c++
- Category
- C++
- Title
- string to vector c++
- Category
- C++
- Title
- container class in c++
- Category
- C++
- Title
- how to ensure the user inouts a int and not anything else c++
- Category
- C++
- Title
- c++ find prime numbers
- Category
- C++
- Title
- c++ switch case statement
- Category
- C++
- Title
- case label in c++
- Category
- C++
- Title
- stringstream in c++
- Category
- C++
- Title
- what is meaning of 64 bit integer in c++
- Category
- C++
- Title
- repeating character in c++
- Category
- C++
- Title
- insert at position in vector c++
- Category
- C++
- Title
- c++ excel cell blank cells
- Category
- C++
- Title
- c++ crash windows
- Category
- C++
- Title
- what is c_str()
- Category
- C++
- Title
- gfg right view of tree
- Category
- C++
- Title
- factorial in c++
- Category
- C++
- Title
- how to put a class in a .h file c++
- Category
- C++
- Title
- c++ rainbow text
- Category
- C++
- Title
- c++ assert
- Category
- C++
- Title
- power c++
- Category
- C++
- Title
- roscpp publish int32
- Category
- C++
- Title
- for loop in c++ hackerrank solution
- Category
- C++
- Title
- pop_back
- Category
- C++
- Title
- switch c++
- Category
- C++
- Title
- #include
- Category
- C++
- Title
- c++ code to print hello world
- Category
- C++
- Title
- what is a header in c++
- Category
- C++
- Title
- create a dictionary cpp
- Category
- C++
- Title
- char* to int in cpp
- Category
- C++
- Title
- spicoli
- Category
- C++
- Title
- setbits
- Category
- C++
- Title
- pause the console c++
- Category
- C++
- Title
- convert stirng to int c++
- Category
- C++
- Title
- how to initialize a vector in c++
- Category
- C++
- Title
- c++ give options string
- Category
- C++
- Title
- how to return a vector c++
- Category
- C++
- Title
- loop through words in string c++
- Category
- C++
- Title
- bellman ford algorithm cp algorithm
- Category
- C++
- Title
- c++ evaluate expression
- Category
- C++
- Title
- c++ get ascii value of char
- Category
- C++
- Title
- set in c++
- Category
- C++
- Title
- length of 2d array c++
- Category
- C++
- Title
- size of a matrix c++
- Category
- C++
- Title
- lower bound c++ for array in decreasing order
- Category
- C++
- Title
- convert GLFWwindow* to IntPtr
- Category
- C++
- Title
- error: ISO C++ forbids comparison between pointer and integer [-fpermissive] if(s[i] != "b"){
- Category
- C++
- Title
- mao two drivers c++
- Category
- C++
- Title
- C++ while
- Category
- C++
- Title
- cheap hosting
- Category
- C++
- Title
- c++ try
- Category
- C++
- Title
- c++ cout int
- Category
- C++
- Title
- tellg and seekg c++
- Category
- C++
- Title
- visual studio 2019 c++ tutorial project
- Category
- C++
- Title
- make an x using asterisk c++
- Category
- C++
- Title
- pass vector by reference c++
- Category
- C++
- Title
- c++ parse int
- Category
- C++
- Title
- c++ call method in same class
- Category
- C++
- Title
- FInd the element which appears more than n/2 times C++
- Category
- C++
- Title
- how to type cast quotient of two integers to double with c++
- Category
- C++
- Title
- subtracting two large numbers
- Category
- C++
- Title
- c++ stream string into fiel
- Category
- C++
- Title
- c++ string to integer without stoi
- Category
- C++
- Title
- how to use winmain function
- Category
- C++
- Title
- c++ random numbers
- Category
- C++
- Title
- adding element in vector c++
- Category
- C++
- Title
- c++ server service ros
- Category
- C++
- Title
- max three values c++
- Category
- C++
- Title
- c++ course
- Category
- C++
- Title
- hello world c++
- Category
- C++
- Title
- stringstream in c++ with delimiter
- Category
- C++
- Title
- c++ max of array
- Category
- C++
- Title
- how to print a string to console in c++
- Category
- C++
- Title
- c++ allocate dynamic with initial values
- Category
- C++
- Title
- iterate const vector
- Category
- C++
- Title
- get line C++
- Category
- C++
- Title
- c++ read_ascii
- Category
- C++
- Title
- how to sort an array according to another array c++
- Category
- C++
- Title
- Given an undirected graph, count the number of connected components.
- Category
- C++
- Title
- sfml default program
- Category
- C++
- Title
- formal parameter c++
- Category
- C++
- Title
- c++ files
- Category
- C++
- Title
- check if key exists in map c++
- Category
- C++
- Title
- c++ size_t
- Category
- C++
- Title
- c++ vector constructors
- Category
- C++
- Title
- count a character in a string c++
- Category
- C++
- Title
- calling by reference and pointers c++
- Category
- C++
- Title
- ue4 c++ how to open a blueprint widget
- Category
- C++
- Title
- how to convert a string to a double c++
- Category
- C++
- Title
- map.erase in c++
- Category
- C++
- Title
- calculate factorial
- Category
- C++
- Title
- can you use rand to read in from an external file inc++
- Category
- C++
- Title
- generate random uniform distribution c++
- Category
- C++
- Title
- std::reverse
- Category
- C++
- Title
- c++ declare variable
- Category
- C++
- Title
- how to convert number to string
- Category
- C++
- Title
- what does map.count() return in c++
- Category
- C++
- Title
- catalan number calculator
- Category
- C++