Write a c++program for calculator with addition,sub
Answers
Answer:
# include <iostream>
using namespace std;
int main()
{
char op;
float num1, num2;
cout << "Enter operator either + or - or : ";
cin >> op;
cout << "Enter two operands: ";
cin >> num1 >> num2;
switch(op)
{
case '+':
cout << num1+num2;
break;
case '-':
cout << num1-num2;
break;
default:
// If the operator is other than +, - error message is shown
cout << "Error! operator is not correct";
break;
}
return 0;
}
plz follow me or mark as brainliest
Answer:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a, b,c;
cout<<"\nEnter any number";
cin>>a;
cout<<"\nEnter another number";
cin>>b;
cout<<"\nPress 1 for addition";
cout<<"\nPress 2 for subtraction";
cout<<"\nEnter your choice";
cin>>c;
switch(c)
{
case 1:cout<<a+b;
break;
case 2:cout<<a-b;
break;
default:cout<<"Wrong choice! ";
}
getch();
}