I get what you're going for. The actual solution might be odd, because you need to start with at least two operands.
Maybe something like this. (It's untested, turn in/copy at your own risk)
Code:
char op = '\0';
double a[2] = {0.0, 0.0};
scanf("%lf%c%lf", &a[0], &op, &a[1]);
a[0] =
(op == '+')? a[0] + a[1] :
(op == '-')? a[0] - a[1] :
(op == '*')? a[0] * a[1] :
(op == '/' && a[1] != 0.0) ? a[0] / a[1] :
0.0;
while (op != '=')
{
printf("\t%f\n", a[0]);
scanf("%c", &op);
if (op == '=')
{
printf("\t%f\n", a[0]);
break;
}
else
{
scanf("%lf", &a[1]);
if (op == '+')
a[0] += a[1];
else if (op == '-')
a[0] -= a[1];
else if (op == '*')
a[0] *= a[1];
else if (op == '/')
{
if (a[1] == 0)
{
printf("\t%s\n", "Error.");
break;
}
else
a[0] /= a[1];
}
}
}
This way the user can do things like
2+2
4
*3
12
:
:
a[0] always stores the running answer.