[C language learning] Three processes when the program is executed

When C language program is executed, there are three most common processes:

(1) Sequential execution process;

(2) Conditional branch selection process;

(3) Cycle execution process.

Some readers may point out that there is also a process for using goto statements. Because the jump generated by the goto statement will cause confusion in the program, the goto statement is not included here.

1. Sequential execution process

The sequential execution flow of a C program means that the statements of the program are executed one by one in order from the front to the back.

Sequential execution flow is the most basic execution flow.

Second, the conditional branch process

The branch process refers to selecting the branch to be executed according to the conditions, and there are two forms:

(1) if...else... process : Refers to the logic judgment when the software is executed, the logic result is true to execute a branch, and the false to execute another branch.

In the if...else... process, else can be absent.

In addition, you can insert the if...else... process in the two clauses of if...else....

(2) switch...case... process: During the software execution, logical judgment is made. The judgment result may have multiple values. Take a value for each result and execute the corresponding process.

Three, cycle process

According to logical conditions, a piece of code is executed repeatedly.

There are three main forms of circulation process:

(1)  while (condition)... form: always execute when the condition is met;

(2) do...while(condition) form: execute at least once, and judge whether it needs to continue execution at the end of execution;

(3) for(...) ... form, this form is more flexible, you can set the initial value, test the loop condition, and set the loop once in the parentheses.

 

In addition, if you want to better improve your programming ability, learn C language and C++ programming! Overtaking in a curve, one step faster! I may be able to help you here~

Sharing (source code, actual project video, project notes, basic introductory tutorial)

Welcome partners who change careers and learn programming, use more information to learn and grow faster than thinking about it yourself!

Free study books:

Free learning materials:

Guess you like

Origin blog.csdn.net/weixin_45713725/article/details/114671443
Recommended