- Joined
- Aug 12, 2022
- Messages
- 6
- Reaction score
- 0
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char c;
double a=0.0, b=0.0;
do
{
system("cls");
printf("==============\nCCurrent Values: \n");
printf("a= %.2f, b= %.2f and a+b= %2.f", a, b,
a+b);
printf("\n\nYour Menu: ");
printf("\na) Enter a new value for a");
printf("\na) Enter a new value for b");
printf("\nq) Quit");
printf("\n Enter your choice:");
scanf(" %c", &c);
switch (c)
{
case 'A':
case 'a': printf("Enter value for a:");
scanf(" %lf", &a);
break;
case 'B':
case 'b': printf("Enter value for b:");
scanf(" %lf", &b);
break;
default: break;
}
} while (c!='q' && c!='Q');
return 0;
}