From the point of view of program flow, the program can be divided into three kinds of basic structure, namely sequential structure, branch structure and cyclic structure. These three basic structures can be composed of all kinds of complex programs. The C language provides a variety of statements to implement these program structures. This article will introduce these basic sentences and their applications, so that readers have a preliminary understanding of the C program, to lay the foundation for future learning.
The statement of the C program
The execution part of the C program is made up of statements. The function of the program is also implemented by executing the statement.
The C statement can be grouped into the following five categories:
1. Expression statements
2. Function Call statement
3. Control statements
4. Compound statement
5. NULL statement
1. Expression statements
An expression statement consists of an expression plus a semicolon ";". The general form is: an expression; Executing an expression statement is a value that evaluates an expression. For example: x=y+z; Assignment Statement y+z; Addition Operation statement, but the results can not be retained, no practical significance i++; Self-Add 1 statement, I value increase 1
2. Function Call statement
Consists of the function name, the actual parameter plus a semicolon ";". Its general form is: function name (actual parameter table); The execution function statement calls the function body and assigns the actual parameter to the formal parameter in the function definition, then executes the statement in the body of the function, and then takes the function value. (described in detail in chapter fifth functions) such as printf ("C program"); Call library function, output string.
3. Control statements
The control statement is used in the process of controlling the program to realize the various structural ways.
They consist of a specific statement definition character. C language has nine kinds of control statements. Can be divided into the following three categories:
(1) Conditional judgment statement
If statement, switch statement
(2) Loop execution statement
Do While statement, while statement, for statement
(3) Turning statement
Break statement, Goto statement, continue statement, return statement