This is a program im trying to get to work for my test :-(
Code:
#include <stdio.h>
int main (void)
{
float value1;
float accumulator = 0;
char operator;
printf ("\t\tCalulator\n");
printf ("\t\t---------\n");
printf("Type in your test\n");
scanf("%f %c", &value1, &operator);
do
{
switch (operator)
{
case 'S':
accumulator = value1;
printf("%.3f\n", value1);
break;
case 's':
accumulator = value1;
printf("%.3f\n", value1);
break;
case '+':
accumulator += value1;
printf("%.3f\n", accumulator);
break;
case '-':
accumulator = accumulator - value1;
printf("%.3f\n", accumulator);
break;
case '/':
accumulator = accumulator / value1;
printf("%.3f\n", accumulator);
break;
case '*':
accumulator = accumulator * value1;
printf("%.3f\n", accumulator);
break;
case 'E':
printf("End of Tests\n");
break;
case 'e':
printf("End of Tests\n");
break;
default:
printf("UNKNOWN OPERATOR\n");
break;
}
while (operator != 'e' && operator != 'E')
printf("\n%.3f\n", accumulator);
return 0;
}
//compiling error
prog6.4.c: In function ‘main’:
prog6.4.c:72: error: expected expression before ‘}’ token
prog6.4.c:79: error: expected ‘while’ at end of input
prog6.4.c:79: error: expected declaration or statement at end of input