1 operator expression and statement 1.1 basic operator 1.1.1 =
Data objects: Refers to the storage area of data in memory
Lvalue: Represents a data object that can be changed
Rvalue: The amount of value that can be assigned to an Lvalue
1.1.2 +
Add
1.1.3–
Reducing
1.1.4 *
By
1.1.5/
Except
1.1.6%
Take the remainder
1.1.7 + =
Plus equals
1.1.8-=
Minus equals
1.1.9 *=
Multiply equals
1.1.10/=
except equal to
1.1.11%=
The remainder equals
1.1.12 + +
Self-Added 1
, i++ evaluates the value of the expression before the + +
, ++i is first + +, and then the value of the expression is evaluated
1.1.13--
Self-reduction One
1.1.14 comma operator
int a = 2; int b = 3; int c = 4; int d = 5; int i = (A = b, C + D); |
The comma expression first asks the value to the left of the comma, then the value to the right, and the value of the entire statement to the right of the comma.
1.1.15 Operator Precedence
Priority level |
Operator |
Binding nature |
1 |
+ + (suffix),--(suffix), () (call function), {} (statement block),.,-> |
From left to right |
2 |
+ + (prefix),--(prefix), + (prefix),-(prefix),! (prefix), ~ (prefix), sizeof,* (fetch pointer value),& (Fetch address), (type) (conversion) |
From right to left |
3 |
*, /, % |
From left to right |
4 |
+,- |
From left to right |
5 |
<< >> |
From left to right |
6 |
< > <= >= |
From left to right |
7 |
== != |
From left to right |
8 |
& |
From left to right |
9 |
^ |
From left to right |
10 |
| |
From left to right |
11 |
&& |
From left to right |
12 |
|| |
From left to right |
13 |
? |
From right to left |
14 |
=,*=,%=,+=,-=,<<=,>>=,&=,|=,^= |
From right to left |
15 |
, (comma operator) |
From left to right |
1.2 Compound statement
{} code block
1.3 Empty statements
There is only one; the statement of the number is an empty statement, the empty statement is in the C language and is legal, and is necessary for certain occasions
1.4 Type Conversions
() is a forced type conversion operator
#include <stdio.h>intMain01 () {intA =Ten; intb =3; intc = a%b; printf ("C =%d\n", c); //A = a + 5;//grammatically correct, but a rookie.A + =5; A= A +1; A+=1; A++; A= A-1; A-=1; A--; return 0;}intmain02 () {inti =5; //i++; //++i; //int a = ++i; //int a = i++; intA = i++ + + +i; //i = i + 1; //int a = i + i; //i = i + 1;printf ("%d\n", a); printf ("%d\n", i); return 0;}intmain03 () {intA =2; intb =3; intc =4; intD =5; inti = (A = b, A +d); printf ("i =%d\n", i); A=2; b =3; c =4; D =5; I= (A + (B-C)) *D; printf ("i =%d\n", i); A=4; b=3; C=8; I= A = b =C; printf ("i =%d\n", i); {i= -; A= -; } ;//Empty Statementprintf ("i =%d\n", i); for(; ; )//Loop statement, which represents code inside a compound statement to be executed 3 times{printf ("hello\n"); } return 0;}intMain () {//double f = 3/2;//The result of dividing two integers in C is automatically converted to an integer//double f = (double) 3/2;//(Double) 3, which means that the integer 3 is coerced into a double type//double f = 3.0/2; intA =3; intb =2; DoubleF = (DoubleAb; printf ("%f\n", F); return 0;}
Source: Intelligence Podcast for study only
Data type (eight) operator in 2_c language