Week 11 - Lecture 29 - Intro Function
Week 11 - Lecture 29 - Intro Function
Functions
Dr Taimur Ahmed
Department of IT & CS, PAF-IAST
Lecture# 29
Library Functions & User defined Functions
Why do we need Functions?
Modular Programming
Modular Programming
❑ Modular Programming:
❑ Breaking a program into small, manageable modules
❑ Function:
❑ A collection of statements to perform a task
❑ Motivation for modular programming
➢ Simplifies the process of writing programs
➢ Improves maintainability of programs
➢ Helps programmer to understand purpose of each module in the program
❑ Library/standard Functions
❑ Already defined in the header files
Function header
int main()
{
Function
cout << “Hello! << endl; definition
return 0;
}
Function header
int main()
{
cout << “Hello! << endl; Function
definition
return 0;
}
void printHeading()
{
cout << "Monthly Sales\n";
}