C language definition

Source: Internet
Author: User

1, c program is composed of functions. A C source program contains at least one main function, or it can contain a main function and several other functions. Therefore, the function is the basic unit of the C program. The called function can be a system-provided library function (such as printf and scanf functions), or it can be a function that the user designs on their own, such as

 int  Max (int  x, int   y)  /*   Define the Max function, the function value is integer, formal parameter x, y is integer  */ {  Span style= "COLOR: #0000ff" >int  z; /*   In the Declarations section of the Max function, define the variable z used in this function as Integer  */ if    (x>y) Z=X;    else  z=y;           return  (z); /*   */ }  

)。 The function of C is equivalent to subroutines in other languages. Use functions to implement specific functions. All the work of the program is done by each function, writing a C program is to write a function.

2. A function consists of two parts:

A, the header of the function, that is, the first line of the function, including the function name, function type, function property, function parameter (formal parameter) name, parameter type. As the top of the Max function, the header is:

int max (int x, int y)

↓↓↓↓↓↓

function type function name function parameter type function parameter name function parameters type function argument name

A function name must be followed by a pair of parentheses, the parameter name of the function is written in parentheses, and its type. The function can have no parameters, such as Mian ().

b, the function body, that is, the part of the curly braces below the first part of the letter. If there are multiple curly braces within a function, the outermost pair of curly braces is the function body range.

The function body generally consists of the following parts.

Declaration section. In this section, you define the variables used and the declarations of the functions that are called. The declaration "int max (int x,int y)" of the calling function Max is as above.

Execution section. consists of several statements.

Of course, in some cases there can be no declaration part, or even neither a declaration part nor an execution part. Such as:

    void  dump ()    {    }

He is an empty function and does nothing, but it is legal.

3. A c program is always executed from the main function, regardless of the location of the main function in the entire program (the main function can be placed at the very beginning of the program, or at the end of the program, or before some functions, or after some other function).

4, c program writing format is free, a line can write several statements, a sentence can be divided into multiple lines, c program no line number.

5. Each statement and data declaration must have a semicolon at the end. A semicolon is a necessary part of a C statement. such as: "C=A+B;" semicolons are indispensable. Even the best statement of the program should contain a semicolon.

6, the C program itself does not have input and output statements. The input and output operations are performed by functions such as library functions scanf and printf. C "function" for input and output. Because the input and output operation involves specific computer equipment, the input and output operations in the function of processing, you can make the C language itself is small, the compiler is simple, it is easy to implement on a variety of machines, the program is portable. In addition to providing standard functions, different computer systems provide specialized functions, so the number of functions and functions available in different computer systems are varied.

7. You can use/*..........*/to annotate any part of the C program. A good, use-value source program should add the necessary annotations to increase the readability of the program.

The above content from reading rectification Authoring C programming language design, for personal notes! Individuals and groups are prohibited from being used for commercial purposes, as explained here!

C language definition

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.