Download presentation
Presentation is loading. Please wait.
1
Functions Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences National Cheng Kung University Last updated: 12 October 2004 Chapter 5
2
Functions Definition Act on data and return a value Two categories User-defined Built-in Declare and define #include a file with prototypes Put all prototypes in the beginning of your code Call the prototype right before use it Three bad reasons to do so
3
Function prototypes Example Legal but not good to include names of parameters Ex5-1
4
Defining the function Header Body Syntax
5
Variables Local variables Ex5-2 Global variables Ex5-3 Dangerous but necessary in C A good alternative in C++ Scope
6
Some good habits to design a function Short Carry out a single, easily understood task Be explicit Don’t use functions as parameters to functions Local variables are local variables Ex5-5
7
Overloading functions Function polymorphism Ex5-8
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.