I. numeric type
1. Representation of real constants: 3.5 (Double Precision), 3.5f (single precision), and 3.5l (Long Double Precision)
2. integer constant: a char character constant ('A', 'B', '0') used as an integer constant for calculation.
3. Numbers and numbers (ascll) are sequential connections
Ii. control statements
1. Difference Between while and do while: When the while condition is not true, the while () loop does not execute the loop statement, while the do while clause will execute the loop statement cyclically and then judge
2. Process Control statement: Continue (interrupt this loop) Break (jump out of the entire loop)
3. Switch
Switch usage
Switch (integer expression ){
Case integer constant expression 1: Statement sequence 1;
Case integer constant expression 2: Statement sequence 2;
}
Note:
1. The switch judgment type is an integer.
2. A case can only be followed by an integer constant expression.
3. Switch can only be used for integer operations, and the operation results are fixed Integer constants.
4. The default (default) option is always at the front no matter where the position is. When CSS is not set, the final judgment is made.
5. Not all condition judgments are suitable for Switch
III. C program structure and variables
1. Global Variables
Variables declared outside all functions are called global variables.
Scope: (range) from the declared statement to the end of the file
Lifetime: starts and exists from the declared statement until the program running ends.
Note: The global variable can be called again, and the initial value is used.
2. Local variables (automatic variables) Auto int X;
Parameters declared in the function body (including formal parameters) are called local variables.
Scope: only works in the function body.
Lifetime: It starts to exist when the function runs. When the function ends, the local variable is released (disappears)
Note: local variables can be renamed with global variables within the range of local variables.
3. Static local variable static int y;
Parameters declared in the function body (including formal parameters) are called local variables.
Scope: only works in the function body.
Lifetime: It exists when the program runs and the occupied memory is released until the program ends.
4. Constant variable --- Changshu variable
It is a variable and its value can be defined by assigning an initial value, but its value cannot be changed during running.
4. Preprocessing: What we do before compilation is called preprocessing.
1. File Inclusion # include <stdio. h> # include <math. h>
2. macro definition and macro replacement (occur in Preprocessing)
# Define (defined) SLD (initial name) Static long double (replace content)
SLD x = 2.4, y = 3.5;
Macro replacement with Parameters
# Define min (A, B) (a) <(B )? (A) (B ))
Z = min (x + y, x * Y); (x + y) <(x * Y )? (X + y) :( x * y ))
5. Common constant definition methods
1. Definition of const constant variables
2. Use macro replacement to define constant variables
3. Use Enum to implement (Enumeration type) const int out = 10; conts int in = 3;
Enum {out = 10, in = 3 };
Vi. bitwise operators
Logical operator! (Reverse) & (and) | (OR)
Bitwise operators
X y! X (inverse) X & Y (and) x | Y (OR) x ^ y (exclusive or)
1 1 0 1 1 0
1 0 0 0 1 1
0 1 1 0 1 1
0 0 1 0 0 0
Chapter v c program structure