Simple Calculator in C++

Write a simple calculator program in C++. It should input two numbers and a character. If the character is ‘+’, it should add two numbers and so on.

using namespace std;
int main(){
	int a,b;
	char c;
	cout<<"Enter two numbers : "<<endl;
	cout<<"a : ";
	cout<<"b : ";
	cout<<"Enter any character(+-*/%) : ";
	cout<<"Result : ";
		case '+':cout<<a+b;break;
		case '-':cout<<a-b;break;
		case '*':cout<<a*b;break;
		case '/':cout<<a/b;break;
		case '%':cout<<a%b;break;
		default :cout<<" ?";
	return 0;
output of calculator program
output of calculator program

One Reply to “Simple Calculator in C++”

Leave a Reply

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