新手代码,大佬勿喷,自己学习过程中的一些记录。
#include<stdio.h>
void show_menu(void);
double input_first(void);
double input_second(char ch);
void output_result(char ch, double num1,double num2);
int main()
{
double num1 = 0.0, num2 = 0.0;
char ch;
show_menu();
ch = getchar();
while (ch != 'q')
{
//input
num1 = input_first();
num2 = input_second(ch);
//output
output_result(ch, num1, num2);
show_menu();
ch = getchar();
while (ch != 'a' && ch != 'm' && ch != 'd' && ch != 's' && ch != 'q')
ch = getchar();
}
printf("Bye!");
return 0;
}
void show_menu(void)
{
printf("Enter the operation of your choice:\n");
printf("a. add s. subtract\n");
printf("m. multiply d. divide\n");
printf("q. quit\n");
}
double input_first(void)
{
double n=0;
int check;
ch