简单计算器求助
小弟初学C语言,按照书上的要求写个可以连续计算的计算器,但goto语句的运用不对,求大神指点// 简单四则运算计算器
#include<stdlib.h>
#include<stdio.h>
int main()
{
there:
double number1 = 0.0; //初始化被除数
double number2 = 0.0; //初始化除数
char operation = '0';
printf("\n输入算式\n");
scanf("%lf%c%lf",&number1,&operation,&number2); //输入符合规定的算式
/*检查输入的运算符号*/
switch(operation)
{
case '+':
printf("= %lf\n",number1 + number2);
break;
case '-':
printf("= %lf\n",number1 - number2);
break;
case '*':
printf("= %lf\n",number1 * number2);
break;
case '/':
if(number2 == 0)
printf("\n\n除数不能为零!");
else
printf("= %lf\n",number1 / number2);
break;
case '%':
if((long)number2 == 0)
printf("\n\n除数不能为零!!");
else
printf("= %ld\n",(long)number1 % (long)number2);
break;
default:
printf("\n\n非法操作!");
break;
}
char con;
printf("\n继续运算? Y or N \n");
if((con = getchar()) == 'y'||'Y')
goto there;
if((con = getchar()) == 'n'||'N')
exit(0);
return 0;
}