menu search
person
To write C++ Program using operators
thumb_up_alt 0 like thumb_down_alt 0 dislike
5 views

1 Answer

 
verified
// Program to perform given operation on two input integers 
#include<iostream.h> {

void main()

{

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)

{

} else



f=(float)a/b;

cout<<"the result is : "<<f;

}

}

else 

cout<<"invalid operator";

}
thumb_up_alt 0 like thumb_down_alt 0 dislike
...