一、赋值
符号 = , 将右边的值赋给左边
例如: a =3;
b= a + 1;
unsigned char ucTemp;
signed char cTemp;
unsigned int usTemp;
unsigned long int ulTemp;
float fTemp;
ucTemp = 200;
printf("The ucTemp = %u\r\n",(unsigned int)ucTemp);
cTemp = -100;
printf("The cTemp = %d\r\n",(signed int)cTemp);
fTemp = 0.25;
printf("The fTemp = %.2f\r\n",fTemp);
//强制类型转换
fTemp = 30.4;
printf("The fTemp = %d\r\n",(unsigned int)fTemp); //打印结果为30 舍弃0.4
二、加减乘除法
三、取余
四、加1 ,减1
五、综合运用
六、关系运算符
1.等于或不等于.
2.大于或大于等于
3.小于或小于等于
七、三目运算符
MAX = (a>b)?a:b;
printf("The MAX = %u\r\n",MAX);
MAX = (a<b)?b:a;
printf("The MAX = %u\r\n",MAX);
MAX = (a>=b)?a:b;
printf("The MAX = %u\r\n",MAX);
MAX = (a<=b)?b:a;
printf("The MAX = %u\r\n",MAX);