Week 2, Introduction To Functions
Week 2, Introduction To Functions
• Examples
• Function definition
• Function prototypes & Header files
• Pre- and post-conditions
• Scope and storage class
• Implementation of functions
• Recursive functions
N = f(pi*pow(r,2), b+c) + d;
• #include "foo.h"
• Search the directory where the source program is
found first, before -I and system directories
CS-2301, B-Term 2009 Introduction to Functions 24
Typical C Programming Style
int GetNewItem(void) {
float input;
int rc;
printf("Enter next item:- ");
if ((rc = scanf("%f", &input)) != EOF
&& (rc > 0)) {
total += input;
count++;
}; // if
return rc;
} // GetNewItem