Presentation is loading. Please wait.

Presentation is loading. Please wait.

Functions Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences National Cheng.

Similar presentations


Presentation on theme: "Functions Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences National Cheng."— Presentation transcript:

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


Download ppt "Functions Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences National Cheng."

Similar presentations


Ads by Google