teach me.

this is my code for c++.

#include <stdio.h>
int main()
{
float num1, num2;
char op, sum[256];
gets(sum);




{

sscanf(sum, "%f %c %f", &num1, &op, &num2);
if(op == '+')
{
printf("Answer:%f + %f = %f", num1, num2, num1 + num2);
}
else if(op == '-')
{
printf("Answer:%f - %f = %f", num1, num2, num1 - num2);
}
else if(op == '*')
{
printf("Answer:%f * %f = %f", num1, num2, num1 * num2);
}
else if(op == '/')
{
printf("Answer:%f / %f = %f", num1, num2, num1 / num2);
}
else
{
printf("There was an error calculating your request");
}
getchar();
return 0;
}
}


in want to input the sign that show the user can put the number but i can't find the solution
Last edited on
If you can find the solution...just do it >.>
can't firedraco..

sory miss write.
Sorry but I don't understand what you are asking. You want to input the sign the shows the user can put (input?) the number? Do you mean you want to tell the user "Please input an equation of the form a + b, where a and b are decimal numbers and + is a mathematical operator + - / or *"?
Topic archived. No new replies allowed.