c語言有那些運(yùn)算符
1.算術(shù)運(yùn)算符冰肴、邏輯運(yùn)算符屈藐、關(guān)系運(yùn)算符、符值運(yùn)算符
1.算術(shù)運(yùn)算符
- 加 - 減 x 乘 / 除 % 余
邏輯運(yùn)算符 與 && 或 || 非 !
int a,b;
a = 8,b = 0;
//兩個條件同時為真結(jié)果才為真
printf("a&&b = %d\n",a&&b);
//其中有一個為真就為真
printf("a||b = %d\n",a||b);
## 關(guān)系運(yùn)算符
< >= <= == !=
// int a,b,c,e;
// a = 6,b = 8,c = 2,e=6;
// printf("a>b=%d\n",a>b);
// printf("a<b=%d\n",a<b);
// printf("a<=e=%d\n",a<=e);
// printf("a>=e=%d\n",a>=e);
// printf("a!=e=%d\n",a!=e);
// printf("a==e=%d\n",a==e);
// printf("%d",a-e || !c );
//掃描函數(shù)
int aa;
printf("請從控制臺輸入一個整數(shù):");
scanf("%d",&aa);
printf("%d+6的結(jié)果是:%d",aa,aa + 6);
//基本數(shù)據(jù)類型 整型(int) 短整型(short) 長整型(long)
// 單精度浮點型(float) 雙精度浮點開型(double) 字符型(char)
##基本運(yùn)算符 加(+) 減(-) 乘(*) 除(/) 余(%)
//加法運(yùn)算
int a = 9;
char c = '8';
int result = a+c;
//printf("a+c=%d",result);
int aa = 88;
int bb = 99;
long ab = aa+bb;
// printf("aa+bb=%d",ab);
int ac = 44444;
int ad = 44444;
short acd = ac+ad;
//printf("ac+ad=%d",acd);
//減法
double yuWenChengJi = 98.987;
int shuXueChengJi = 88;
// printf("yw-sx=%.3f",yuWenChengJi-shuXueChengJi);
// 乘法
float age = 18.5;
int bc = 3;
// printf("age*bc=%f" , age * bc);
//除法
float fu = 6.66;
int iw = 2;
// printf("fu/iw=%.2f",fu/iw);
float du = 5;
int dw = 0;
// printf("du/dw=%d",du/dw);
//余
int tt = 56;
int aaa =3;
//printf("tt%caaa=%d",'%',tt % aaa);
float ttt = 879.98;
float abaga = 3;
// printf("ttt%cabaga=%d",'%',ttt%abaga);
賦值運(yùn)算符
//++
//float ja = 89.9;
//printf("ja=%.1f\n",ja++);
//printf("ja=%.1f\n",ja++);
//printf("ja=%.1f\n",++ja);
//printf("ja=%.1f\n",ja);
int jaa = 55;
printf("jaa=%d\n",++jaa); // 56
printf("jaa=%d\n",jaa++); //56
printf("jaa=%d\n",++jaa); //58
printf("jaa=%d\n",jaa++); //58
printf("jaa=%d\n",1+jaa++); //60
printf("jaa=%d\n",jaa); //60