Lecture04 Functions
Lecture04 Functions
Objectives
‣ to learn about functions and how to use them to
write programs with separate modules variables
2
Function
‣ also called subroutine, chunk of code, building block of a
program
stdio.h
math.h
4
Some
Mathematical
Library Functions
5
Writing your own Functions
A Function must have:
1. return type
5. a return value
6
Writing your own Functions
7
Writing your own Functions
Functions with no parameter and no return type
void drawSquare()
{
// prints a 3x3 square
printf(“***\n”);
printf(“***\n”);
printf(“***\n”);
}
Note that:
‣ no parameters
9
Writing your own Functions
Functions with parameter(s) and no return type
Note that:
Note that:
12
Writing your own Functions
13
Writing your own Functions
Parameter
‣ like variables in the sense that they contain values and have
types
Argument
14