C language secondary system learning 3 (branch loop, function)

This study focuses on the two parts of sentences and functions.

Branch statements (if, switch) and loop statements (while, for, do while)

In the switch statement, if there is no break after each selection, the next case will be executed, and attention should be paid to the use of the default statement, which is usually placed behind the {} code block

In the do while statement, the loop will be executed first, and then the judgment will be performed, so it is relatively less used. In the while loop, the judgment condition in () will be used once more than the loop code.

Use the continue statement in the program to jump out of the most recent loop, and generally use the if statement to cooperate.

When using branch and loop statements, you should analyze the logic of the loop beforehand, construct a logical block diagram, and then code.

The function part of the
library function
uses the library function, and must include the header file corresponding to #include. The
custom function
is defined according to the needs. The definition of the function name return value type and function parameter
parameters are divided into actual parameters and formal parameters. Pay attention to their distinction and The difference in use.
The formal parameter instantiation is equivalent to a temporary copy of the actual parameter.
Functions can be nested and call each other.
Function declaration:
1. Tell the compiler the name of the function, what are the parameters, and what is the return type.
2. The declaration of the function should appear before the use of the
function 3. The declaration of the function should be placed in the header file

Guess you like

Origin blog.51cto.com/14955626/2545822