Đang chuẩn bị liên kết để tải về tài liệu:
Kỹ thuật lập trình_Module 5
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'kỹ thuật lập trình_module 5', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Module 5 Introducing Functions Table of Contents CRITICAL SKILL 5.1 Know the general form of a function.2 CRITICAL SKILL 5.2 Creating a Function.2 CRITICAL SKILL 5.3 Using Arguments.3 CRITICAL SKILL 5.4 Using return.5 CRITICAL SKILL 5.5 Using Functions in Expressions.9 CRITICAL SKILL 5.6 Local Scope.11 CRITICAL SKILL 5.7 Global Scope.16 CRITICAL SKILL 5.8 Passing Pointers and Arrays to Functions.18 CRITICAL SKILL 5.9 Returning Pointers.24 CRITICAL SKILL 5.10 Pass Command-Line Arguments to main .26 CRITICAL SKILL 5.11 Function Prototypes.29 CRITICAL SKILL 5.12 Recursion.32 This module begins an in-depth discussion of the function. Functions are the building blocks of C and a firm understanding of them is fundamental to becoming a successful C programmer. Here you will learn how to create a function. You will also learn about passing arguments returning values local and global variables function prototypes and recursion. Function Fundamentals A function is a subroutine that contains one or more C statements and performs a specific task. Every program that you have written so far has used one function main . They are called the building blocks of C because a program is a collection of functions. All of the action statements of a program are found within functions. Thus a function contains the statements that you typically think of as being the executable part of a program. Although very simple programs such as many of those shown in this book will have only a main function most programs will contain several functions. In fact a large commercial program will define hundreds of functions. 1 C A Beginner s Guide by Herbert Schildt CRITICAL SKILL 5.1 Know the general form of a function All C functions share a common form which is shown here return-type name parameter-list body of function Here return-type specifies the type of data returned by the function. This can be any valid type except an array. If the function does not return a value its return type must be void. .