Here is the code.
Code:
#include <stdio.h>#include <conio.h>
#include <math.h>
int main()
{
char choice;
float num1,num2;
do
{
printf("Please enter a numbers number: ");
scanf("%f", &num1);
printf("Please enter another number: ");
scanf("%f", &num2);
printf("Please select the option: ");
printf("\n a or A for addition");
printf("\n s or S for subtraction");
printf("\n m or M for Multiplication");
printf("\n d or D for Division");
printf("\n e or E to exit the program: ");
printf("\n ");
scanf("\n%s",&choice);
switch (choice)
{
case 'A':
case 'a':
printf("The sum of the two numbers are: %5.2f\n", num1 + num2);
break;
case 'S':
case 's':
printf("The total is: %5.2f\n", num1 - num2);
break;
case 'M':
case 'm':
printf("The total is: %5.2f\n", num1 * num2);
break;
case 'D':
case 'd':
printf("The total is: %5.2f\n", num1 / num2);
break;
case 'E':
case 'e':
break;
default:
printf("\nPlease pick a valid option:");
}
}while(choice != 'e' || 'E');
return 0;
getch();
}
My problem is when i use e or E the program will not exit. When i take the loop out it works. I need the program to loop until i use e or E. ive tried a few things but no such luck. Any pointers or tips?
any help would be greatly appreciated!