底部printf()
不在控制台上打印运算符变量。但只有number1
和number2
被打印出来。可能是什么原因?
输出: 2 7 是多少?
char operator;
switch(type){
case 1:
operator=='+';
result=number1+number2;
break;
case 2: operator=='-';
result=number1-number2;
break;
case 3: operator=='*';
result=number1*number2;
break;
case 4:
operator=='/';
result=number1/number2;
break;
}
printf("How much is %d %c %d ?",number1, operator, number2);