Ch. 5: Functions

Ch. 5: Functions - Functions Outline Introduction Function...

Info icon This preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Functions Outline Introduction Function Definitions Function Prototypes Function Name by Identifier __func__ Recursive Functions Header Files Random Number Generation Type Generic Functions Function Files Sample Problem Indirect Recursive Functions Variable Number Arguments in Functions Extensions in Ch Nested Functions
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Introduction A C program is generally formed by a set of functions. These functions subsequently consist of many programming statements. By using functions, a large task can be broken down into smaller ones. Functions are important because of their reusability. That is, users can develop an application program based upon what others have done. They do not have to start from scratch.
Image of page 2
Function Definitions A function can be defined in the form of return_type function_name(argument declaration) { statements } Example: int addition(int a, int b) { int s; s = a + b; return s; } int main() { int sum; sum = addition(3, 4); printf(“sum = %d\n”, sum); return 0; }
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon