#include int main() { char ch; double a,b; printf("Enter operator(+,-,*,/)","enter exit press x:"); scanf("%c",&ch); if(ch=='x') exit(0); printf("Enter two operand:"); scanf("%lf %lf",&a,&b); switch(ch){ //for addition case'+': printf("%lf+%lf=%lf",a,b,a+b); break; //for subtraction case'-': printf("%lf-%lf=%lf",a,b,a-b); break; //for multiplication case'*': printf("%lf*%lf=%lf",a,b,a*b); break; //for subtraction case'/': printf("%lf/%lf=%lf",a,b,a/b); break; default: printf("wrong! unavilable press"); } } Output Enter an operator (+, -, *, /), if want to exit press x: + Enter two first and second operand: 7 8 7.0 + 8.0 = 15.0 Enter an operator (+, -, *, /), if want to exit press x:...
Comments
Post a Comment