C language Run is read the main function of the content, sequentially read from the upper and lower order, first encountered a loop, it will be the end of the cycle and then read down. When the choice is over, then read it down . To customize a function, the defined function can be run into the main function if it is before the main function. If you define a function after the main function, you must first declare it before the main function to substitute the main function.
The cyclic structure of C language
The cyclic structure of C language has a while structure, a for structure and a do and 3 structure. The Do-while structure and the other 2 different characteristics are that do is to execute the instruction before judging whether the loop, while the while and for loop structure is first to determine whether to loop the execution of instructions.
Do while (judging condition) for (; judging condition;)
{ { {
instruction, instruction, command, order, instruction
}while (judging condition);}}
C Language Selection structure
The C language selection structure has a switch structure and an IF structure . Switch is used for multi-branch structure programs, which are characterized by distinct and intuitive branches.
switch (expression)
{
case constant Expression 1: statement 1
break;//Without a abort instruction, when a constant expression matches successfully, an expression that does not satisfy the condition is also executed.
case constant Expression 1: statement 1
Break
...
case constant Expression N: statement n
Break
Default: Statement n+1//before all constant expressions are not equal to an expression, the statement is executed.
}
If structure is also a kind of choice structure
if (expression 1)
{
Statement 1;
}
If else (expression 2)
{
Statement 2;
}
...
If else (expression N)
{
Statement N;
}
Else
{
Statement n+1;
}
This structural feature is performed from top to bottom, and when a condition is successfully matched, the first match succeeds even if the following conditions are equally satisfied. In the case of multiple selection conditions, it is not recommended to use the if structure, too chaotic and too miscellaneous error prone, but should choose the switch structure dedicated to multi-branch selection.
Custom functions
We can use custom functions to improve efficiency when we use a program block that uses the same function repeatedly when we are programming. The basic structure of custom functions is:
return value type function name (parameter list)
{
function body
}
Return value type If there is no return value function type, use the void function, which is consistent with the naming and variable naming rules of the function name. The function body is enclosed by a pair of curly braces {}, which can contain a description statement and an execution statement. function functions are implemented by individual statements within the body of the function. If you define a function to unload the main function after main, then you must make a function declaration before the main function, that is:
return value type function name (argument list);//End With semicolon
int main ()
{
.......
}
C Language Program Structure