Chapter 6 Function s Modular structure of structured programs: 模块 1 模块 1.1 …… 模块 1.n 主控模块 模块 2 …… 模块 2 …… 模块 2.n .1 模块 n 模块 n.1 …… 模块 n.n Chapter 6 Function s f1() Procedure structure : f2() { … f21(); … f22(); … } f12() { … } f21() { … } f22() { … } … … main() { … f1(); … f2(); … … fn(); … } { … f11(); … f12(); … } f11() { … } fn() { … fn1(); … fn2() … } fn1() { … } fn2() { … } Chapter 6 Function s According to the different definitions of functions, they can be divided into the following two categories: (1) Standard function: The defined function provided by the system can be called by ordinary users.For example , the input and output functions scanf, printf, getchar, p utchar and so on.Some common library functions in Tu rbo C 2.0 are shown in Appendix D. (2) User-defined functions: functions written by users th emselves to solve specific problems. Chapter 6 Function s According to the parametric form of functions, C language functio ns can be divided into the following two types: (1) Parametric function: The main function does not transfer data t o the called function. (2) Parametric function: When calling a function, there is paramete r transfer between the main function and the called function. That is to say, the main function can transfer data to the called function for use, and the data in the called function can also be brought ba ck for the use of the main function. Chapter 6 Function s Definition and Call of 6.1 Function 6.1.1 Function Definition General form of function definition: Type Identifier Function Name (Formal Parameter Tabl e Column) { Explanation part Executive part Int Max (int x, int y) /* function head*/ } {/* Function Body Begins*/ z; /* Explanatory section*/ Example:Int If (x > y) z = x; /* executive part*/ Else z=y; Return (z); }/* End of Function Body*/ Chapter 6 Function s Definition and Call of 6.1 Function 6.1.1 Function Definition Description: Function definition includes two parts: function he ad and function body. 1) type identifier before the function to the type of the return value o (1)TheFunction header: the first name linerefers of function definition. f the function, referred to as the function value type.The return value of a function is obtained by the return statement in the function, i.e. the value of the expression after return, which can be a simple type, a void type or a construction type, etc.When the t ype of the expression after return is not consistent with the type identifier before the f unction name, the type identifier before the function name is used as the function val ue type (that is, the value of the expression after return is converted to the type befor e the function name is returned as the function value).If there is no return statement i n the function, an uncertain value will be returned; if you want no return value, you c an define the function type as void, and when the function value type is int, you can o mit the description of its type. Chapter 6 Function s Definition and Call of 6.1 Function 6.1.1 Function Definition Description: Function definition includes two parts: function he ad and function body. 2) TheFunction function name is the identifier of theline function. follows thedefinition. naming rules of C lang (1) header: the first of Itfunction uage identifier and distinguishes between case and case. 3) The formal parameter list after the function name gives the formal parameter of the fu nction and its type description.Formal parameters are abbreviated as formal parameters. Formal parameters and their type descriptions are placed in a pair of parentheses after th e function name. It should be noted that, regardless of whether the function has formal pa rameters or not, the parentheses after the function name are not saved, and the parenthes es can not be followed by ";".The general form of the table of formal parameters is as foll ows: Parametric 1 type parametric 1, parametric 2 type parametric 2,...Type n parameter n Chapter 6 Function s Definition and Call of 6.1 Function 6.1.1 Function Definition Description: Function definition includes two parts: function he ad and function body. (1) Functionbody: header: the enclosed first line function (2) Function The part by of curly brackets definition. "{}" after the fu nction description, including the description part and the execution part. 1) Declarations: Used to explain variables and functions used in function s. 2) Execution: It is composed of basic

pptDoc Key Tasks of New Urbanization Construction in 2019

Professional Docs > Common > Other > Preview
51 Pages 0 Downloads 116 Views 3.0 Score
Tips: Current document can only be previewed at most page8,If the total number of pages in the document exceeds page 8,please download the document。
Uploaded by admin on 2019-10-16 00:34:02
Rate
You can enter 255 characters
What is my domain?( answer:www.45doc.com )
comments
  • No comments yet