1. Knowledge Points:
(1) Character type
Char ch;
(Ch >= ' a ' && ch <= ' z ') | | (Ch >= ' A ' && ch <= ' Z ')
(Ch >= ' 0 ' && ch <= ' 9 ')
• Character type data
Character variable: char ch; (defines the character variable ch for storing character data.) )
Character constant: ' A ' z ' ' a ' z ' 0 ' 9 ' \ n ' (2) input and output of character data • Character input function GetChar
Enter a character
Char ch;
ch = getchar ();
• Character output function Putchar
Output one character
Putchar (output parameter); (3) Logical operation
(Ch >= ' a ' && ch <= ' z ') | | (Ch >= ' A ' && ch <= ' Z ')
Ch >= ' 0 ' && ch <= ' 9 '
• Logical operators: &&;| | ;! ;
• Logical expression: A formula that connects a logical operand with a logical operator.
(4) Else–if statement
if (expression 1) Statement 1
else if (expression 2) Statement 2
else if (expression n-1) statement n-1
Else Statement n
(5) Switch statement
Handles multi-branch selection issues in 3 scenarios:
① use the break statement in each statement segment of the switch statement
switch (expression) {
case constant Expression 1: statement segment 1; Break
Case constant Expression 2: statement segment 2; Break
.......
case constant Expression N: statement segment n; Break
Default: statement segment n+1; Break
}
② do not use break in switch
switch (expression) {
case constant Expression 1: statement segment 1;
Case constant Expression 2: statement segment 2;
.......
case constant Expression N: statement segment n;
Default: statement segment n+1;
}
③ using break in certain statement segments of switch
• General form:
switch (expression)
{Case constant-expression 1: statement 1
Case constant Expression 2: statement 2
case constant Expression N: statement n
Default: Statement n+1
}
Job 4 Summary