关键字
Keywords |
|
|
|
auto |
double |
int |
struct |
break |
else |
long |
switch |
case |
enum |
register |
typedef |
char |
extern |
return |
union |
const |
float |
short |
unsigned |
continue |
for |
signed |
void |
default |
goto |
sizeof |
volatile |
do |
if |
static |
while |
操作符
Operator(s) |
Operation(s) |
Order of evaluation |
* |
乘法 |
乘法、除法、余数优先执行。如果有多个同时存在则从左到右执行。 |
/ |
除法 |
|
% |
取余 |
|
+ |
加法 |
加法、减法接着执行,如果有多个同时存在则从左到右开始执行。 |
- |
减法 |
|
Assignment operator |
Sample expression |
Explanation |
赋值运算符 |
案例 |
说明 |
+= |
num += 5 |
num = num + 5 |
-= |
num -= 5 |
num = num - 5 |
*= |
num *= 5 |
num = num *5 |
/= |
num /= 5 |
num = num / 5 |
%= |
num %= 5 |
num = num % 5 |
++ |
num++ |
后置运算num = num + 1 |
|
++num |
前置运算num = num + 1 |
-- |
num-- |
后置运算num = num - 1 |
|
--num |
前置运算num = num - 1 |
前置、后置递增运算案例
#include <stdio.h>
int main(int argc, char* argv[]) {
int index = 5;
printf("index = %d\n", index);
printf("index++ = %d\n", index++);
printf("index = %d\n", index);
printf("++index = %d\n", ++index);
return 0;
}
Standard algebraic equality operator or relational operator |
C equality or relational operator |
Example of C condition |
Meaning of C condition |
标准代数相等运算符或关系运算符 |
C相等或关系运算符 |
C条件示例 |
C条件含义 |
= = = |
== |
x == y |
x等于y |
≠ \neq = |
!= |
x != y |
x不等于y |
> > > |
> |
x > y |
x大于y |
< < < |
< |
x < y |
x小于y |
≥ \geq ≥ |
>= |
x >= y |
x大于或等于y |
≤ \leq ≤ |
<= |
x <= y |
x小于或等于y |
logical operator |
Explanation |
逻辑操作符 |
解释 |
&& |
AND与 |
|| |
OR或 |
! |
NOT非 |
1 条件判断语句
1.1 i f if if语句
if (grade >= 60) {
printf(