 # Question & Answer: he program displays the operations available and outputs the result until the use….. Write a calculator.c program that has an accumulator value set to 0. The program displays the operations available and outputs the result until the user selects the end operator. See output example below (text in blue indicates values typed in by the user). Simple Calculator Program: type a number and an operator, then press enter OPERATORS: + Add – Subtract S Set Accumulator E End Program 12 + acc =12.00 3.3 + acc =15.30 -10 s acc = -10.00 24 + acc =14.00 1 E Final Value: 14.00 Goodbye! You should use a switch statement to carry the operation requested.

#include<stdio.h>

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: he program displays the operations available and outputs the result until the use…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS \$13/PAGE

int main()

{

char oper=’s’;

float num,acc=0;

printf(“Simple Calculator Program:type a number and an operator,then press enter”);

printf(“nnOPERATORS:n+ Add – SubtractnnS Set Accumulator E End Programnn”);

while(oper!=’E’&&oper!=’e’)

{

scanf(“%f %c”,&num,&oper);

switch(oper)

{

case ‘+’:

acc+=num;

printf(“acc =%.2fn”,acc);

break;

case ‘-‘:

acc-=num;

printf(“acc =%.2fn”,acc);

break;

case ‘S’:

acc=num;

printf(“acc =%.2fn”,acc);

break;

case ‘E’:

{

printf(“nFinal Value: %.2fnGoodbye!”,acc);

break;

}

case ‘s’:

acc=num;

printf(“acc =%.2fn”,acc);

break;

case ‘e’:

{

printf(“Final Value: %.2fnGoodbye!”,acc);

break;

}

}

}

return 0;

} 