sizeof () operator
sizeof can be used to calculate a variable or a constant, a data type that accounts for the number of bytes of memory sizeof altogether there are 3 forms of 1.sizeof (variable \ Constant) sizeof (10); char c = ' a '; sizeof (c); 2.sizeof variable \ constant sizeof 10; char c = ' a '; sizeof C; 3.sizeof (data type) sizeof (float); • Note: cannot be the sizeof data type
conditional operators and conditional expressions• The conditional operator is the only three-mesh operator of the C language, meaning that it requires 3 data or expressions to form a conditional expression • Its general form is:
Expression 1? Expression 2: Expression 3 • If expression 1 is true, the operation result of the trinocular operator is the value of expression 2, otherwise the value of expression 3
switch of Process Control
• Select Structure-switch• Simple use of switch (expression) {
Case value 1:
Statement 1;
Break
...
Default
Break
}
Comparison of IF and switch
• Many situations can be interchangeable if used more, more flexible, switch can only be a single value • (Demo input student results, a, such as 5 points of achievement, using switch to the corresponding percentile score)
C Language Basics