Hey all, program works, but one simple program. After starting program and typing in
(number can be any regular float value), there the program is putting
Please help me remove it. Otherwise, code functions correctly.
This exercise was out of one of the C programming books I am reading. Thanks for continuous help!
Code:
/* Write a program that acts as a simple "printing" calculator. The program should allow the user to type in expressions of the form
*
* number operator
*
* The following operators should be recognized by the program:
* + - * / S E
*
* The S operator tells the program to set the "accumulator" to the typed-in number. The E operator tells the program that execution is to end. The arithmetic operations are performated on the contents of the accumulator with the number that was keyed in acting as the second operand. */
#include <stdio.h>
int main(void)
{
float number = 0;
float accuml = 0;
char operator;
printf("Begin Calulations\n");
int i = 1;
while(i <= 10)
{
scanf("%f %c", &number, &operator);
if(operator == 'S')
printf("%.5f\n", number);
else if(operator == '+')
accuml += number;
else if(operator == '-')
accuml -= number;
else if(operator == '*')
accuml *= number;
else if(operator == '/')
accuml /= number;
else if(operator == 'E')
break;
else
printf("Error Operator!\n");
while (i <= 10)
{
printf("%f\n", accuml);
break;
}
}
}