/*create a simple calculator using c programming */
#include"stdio.h"
int main (){
double num1,num2,result;
char operator;
printf ("enter two numbers and type of operator : ");
scanf ("%lf %lf %c",&num1,&num2,&operator );
switch (operator ){
case '+':
result=num1+num2;
printf ("the result is %lf",result);
break;
case '-':
result=num1-num2;
printf ("the result is %lf",result);
break;
case '*':
result=num1*num2;
printf ("the result is %lf",result);
break;
case '/':
result=num1/num2;
printf ("the result is %lf",result);
break;
default:
printf ("invailed operator ");
}
return 0;
}
output output output output
enter two numbers and type of operator : 40
20
*
the result is 800.000000
No comments:
Post a Comment