teach me.

Feb 19, 2009 at 4:51am
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 Feb 19, 2009 at 5:04am
Feb 19, 2009 at 5:00am
If you can find the solution...just do it >.>
Feb 19, 2009 at 5:04am
can't firedraco..

sory miss write.
Feb 19, 2009 at 6:27am
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.