C语言第12讲,实现计算机功能,不报错,可是不计算
#include <stdio.h>
int main()
{
char sentence ;
float result;
printf("enetr your number and operate:");
scanf("%c",&sentence);
int a = sentence;
int b = sentence;
printf("%c",sentence);
if (sentence == '+')
{
result = a + b ;
printf("the result is: %f \n", result);
}
return 0;
}
char类型赋值给int类型会按照它的ASCII码来赋值的
页:
[1]