question im asked to do :
write a program that acts as a simple printing calculator i should accept in the form of number then operator.
The following operators should be reconised '+', '-', '/', '*' 'S' 's' 'E' 'e'
The S operator tells the program to set the accumulator to the typed in number.
The E operator tell the program to excute to the end
Make certain the program checks for division by zero.
My effort so far;
Code:
#include <stdio.h>
int main (void)
{
double value1
float accumulator = 0.0f;
char operator;
printf ("\t\tCalulator\n");
printf ("\t\t---------\n");
printf("Type in your test\n");
scanf("%d, %c", value1, operator);
if (value1 == 0)
printf("Divsion by zero is not allowed");
switch (operator)
{
case 'S':
accumulator = value1;
printf("%2.f\n", value1);
break;
case 's';
accumulator = value1:
printf("%2.f\n", value1);
break;
case '+':
accumulator+= value1;
printf("%2.f\n", value1;
break;
case '-':
accumulator= accumulator - value1;
printf("%2.f\n", value1);
break;
case '/':
accumulator= accumulator / value1;
printf("%2.f\n", value1);
break;
case '*':
accumulator= accumulator - value1;
printf("%2.f\n", value1);
break;
case 'E':
printf("End of Tests");
break;
case 'e':
printf("End of Tests");
break;
default:
printf("UNKNOWN OPERATOR\n");
break;
}
return 0;
}
any help or tips would be great