The basic statement of the C language primary lecture

Source: Internet
Author: User
Tags definition execution expression function definition

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

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.