Simple Calculator using C++ Programming language:
Source code :
Input :
#include<iostream>
#include<string>
using namespace std;
int main()
{
double a1 , b1 , c1 ;
char op;
cout <<"Enter first integer :";
cin >>a1;
cout <<"What do you want to do (+,-,*,/), Please enter :";
cin >>op;
cout <<"Enter the second integer :";
cin >>b1;
switch(op){
case '+':
c1=a1+b1;
cout<<"Sum of two integer :"<<c1;
break;
case '-':
c1=a1-b1;
cout<<"Subtraction of twoo number :"<<c1;
break;
case '*':
c1=a1*b1;
cout<<"Multiplication of two number :"<<c1;
break;
case '/':
c1=a1/b1;
cout<<"Division of two number :"<<c1;
break;
default :
cout<<"Syntax error.";
}
return 0;
}
Output :
Enter first integer :50
What do you want to do (+,-,*,/), Please enter :+
Enter the second integer :30
Sum of two integer :80
--------------------------------
Process exited after 18.86 seconds with return value 0
Press any key to continue . . .
Tags:
Programming
Share: