R
Rafael
Hi Everyone,
I need some help with my calculator program. I need my program to
do 2 arguments and a 3rd, but the 3rd with different operators. Any
help would be great.
Here is my code....
#include <stdio.h>
#include <stdlib.h>
int main ()
{
float a, b;
char oper;
float outp;
printf("Welcome to calculator 1.0.\n");
printf("Please enter 2 or 3 numbers to evaluate: ");
scanf("%f %c %f", &a, &oper, &b);
switch (oper){
case '+':{
outp = (a + b);
break;
}
case '-':{
outp = (a - b);
break;
}
case '*':{
outp = (a * b);
break;
}
case '/':{
outp = (a / b);
break;
}
default:{
printf("**ERROR your %c not known**.", oper);
}
}
printf("Your answer is %f\n", outp);
system("PAUSE");
return 0;
}
I need some help with my calculator program. I need my program to
do 2 arguments and a 3rd, but the 3rd with different operators. Any
help would be great.
Here is my code....
#include <stdio.h>
#include <stdlib.h>
int main ()
{
float a, b;
char oper;
float outp;
printf("Welcome to calculator 1.0.\n");
printf("Please enter 2 or 3 numbers to evaluate: ");
scanf("%f %c %f", &a, &oper, &b);
switch (oper){
case '+':{
outp = (a + b);
break;
}
case '-':{
outp = (a - b);
break;
}
case '*':{
outp = (a * b);
break;
}
case '/':{
outp = (a / b);
break;
}
default:{
printf("**ERROR your %c not known**.", oper);
}
}
printf("Your answer is %f\n", outp);
system("PAUSE");
return 0;
}