This program works fine , right up to when i enter 0E for example to end tests it doesnt do anything its not ending nor printing out the printf statement
Code:#include <stdio.h> int main (void) { float value1; float accumulator = 0; char operator; printf ("\t\tCalulator\n"); printf ("\t\t---------\n"); do { printf("Type in your test\n"); scanf("%f %c", &value1, &operator); switch (operator) { case 'S': accumulator = value1; printf("%.2f\n", value1); break; case 's': accumulator = value1; printf("%.2f\n", value1); break; case '+': accumulator += value1; printf("%.2f\n", accumulator); break; case '-': accumulator = accumulator - value1; printf("%.2f\n", accumulator); break; case '/': accumulator = accumulator / value1; printf("%.2f\n", accumulator); break; case '*': accumulator = accumulator * value1; printf("%.2f\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%.2f\n", accumulator); return 0; }



LinkBack URL
About LinkBacks



