Professional Documents
Culture Documents
Topic 4.1 Introduction To Functions (STD)
Topic 4.1 Introduction To Functions (STD)
Chapter 4
Functions
By the end of this chapter, students will be able to:
Explain how a function works
Differentiate between local and global variables
Analyze programs that use functions
Write programs that use functions to solve problems
Topic 4.1
Introduction to Functions
By the end of this chapter, students will be able to:
Explain how a simple function works
Describe the structure of functions
Analyze programs that use simple functions
Write programs that use simple functions to solve problems
• User-defined Functions
• These are functions written by programmers, like yourself, so that the
code can be reused and the program will be more readable
void BigE(void);
void BigY(void);
void main(void)
***** {
* BigE();
**** BigY();
* BigE();
}
*****
void BigE(void)
* * {
* * printf(" *****\n");
* printf(" *\n");
* printf(" ****\n");
* printf(" *\n");
printf(" *****\n\n");
}
*****
* void BigY(void)
**** {
* printf(" * *\n");
***** printf(" * *\n");
printf(" *\n");
printf(" *\n");
printf(" *\n\n");
}
Do it
4.1a: How
What next? Functions Work What happened?
Check point:
========================
Tony Stark
========================
Diploma in AI & Robotics
School of Engineering
T.O.P. Polytechnic
For reflection, you may consider the following:
========================
How many times the Line() function is called, and how many
times it is defined. What is your conclusion?
Check point:
Check point:
Enter an integer: 12
The square of 12 is 144.