Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 3

#include<iostream.

h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,d,e;
char oper;
float f;
cout<<"ENTER THE FIRST NUMBER:";
cin>>a;
cout<<"Enter the operator:";
cin>>oper;
cout<<"ENTER THE SECOND NUMBER:";
cin>>b;
if(oper == '+')
{
c=a+b;
cout<<"the result is:"<<c;
}
else if(oper =='-')
{
d=a-b;
cout<<"the result is:"<<d;
}
else if(oper =='*')
{
e=a*b;
cout<<"the result is:"<<e;
}
else if(oper =='/')
{
if(b==0)
{
cout<<"denominator should not be 0";
}
else
{
f=(float)a/b;
cout<<"the result is :"<<f;
}
}
else
cout<<"INVALID OPERATOR";
getch();
}
addition

subtraction
multiplication

division

You might also like