C Language Learning Tutorial Chapter III-C language programming preliminary (9)

Source: Internet
Author: User
Tags continue empty execution expression goto printf

Summary

1. From the procedure implementation process, the program can be divided into three basic structures: sequential structure, branching structure and cyclic structure

2. The most basic unit of execution in a program is a statement. C-language statements can be divided into five categories:
(1) An expression statement with a semicolon at the end of any expression constitutes an expression statement, and the commonly used expression statement is an assignment statement.
(2) The function call statement consists of a function call with a semicolon that makes up the function call statement.
(3) The control statement is used in the program procedure, which consists of a special statement definition character and the desired expression. The main conditional judgment executes the statement, the circular executes the statement, the turning statement and so on.
(4) A compound statement consists of {} to enclose multiple statements to form a statement. A compound statement is considered a single statement, and it can appear in all places where statements are allowed, such as the loop body.
(5) Empty statements consist only of semicolons, without actual functionality.

The 3.C language does not provide a dedicated input and output statement, all input and output are implemented by calling the input and output functions in the standard library functions.
The scanf and GETCHAR functions are input functions that receive input data from the keyboard.
SCANF is a format input function that allows you to enter any type of data in a specified format.
The GetChar function is a character input function that receives only a single character.
The printf and Putchar functions are output functions that output data to the monitor screen.
printf is a format output function that displays any type of data in the format you specify.
Putchar is a character display function that displays only a single character.

4. Relational expressions and logical expressions are two important expressions that are used primarily for judgment of conditional execution and for circular execution.

The 5.C language provides several forms of conditional statements to form a branching structure.
(1) If statement is mainly used for one-way selection.
(2) The If-else statement is mainly used for two-way selection.
(3) If-else-if language and switch statements are used for multi-directional selection.
Conditional statements of these forms are generally interchangeable.

The 6.C language provides three kinds of looping statements.
(1) For statements are mainly used for the given cyclic variable initial value, step increment and cyclic structure of the number of cycles.
(2) Cycle times and control conditions the loop that is to be determined during the loop is available as a while or Do-while statement.
(3) Three kinds of circular statements can be nested together to form multiple loops. Loops can be tied but not crossed.
(4) The transfer statement can be used to transfer the flow outside the circulation body, but not from the outside to the circulation body.
(5) In the circular process should avoid the death cycle, that is, should ensure that the value of the cyclic variable in the course of the operation can be modified, and make the cycle conditions gradually become false, thus ending the cycle.

Summary of 7.C language statements
Name General form
Simple statement expression statement expression;
Empty statement;
Compound Statement {statement}
Conditional statement if (expression) statement;
if (expression) statement 1; Else Statement 2;
if (expression 1) statement 1; else if (expression 2) statement 2...else statement N;
Switch statement switch (expression) {case constant expression: statement ... default: statement;}
Loop statement while statement
while (expression) statement;
For statement for (expression 1; expression 2; expression 3) statement;
Break statement break;
Goto statement Goto;
Continue statement continue;
Return statement return (expression);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.