Electron microscopy
 
MAIN Function in C++ and DM
- Practical Electron Microscopy and Database -
- An Online Book -
Microanalysis | EM Book                                                                                   http://www.globalsino.com/EM/        


=================================================================================

 

MAIN() is the only function that any C++ program must include and is special because it is the first function called when your program executes. This function is also where program execution begins.

 

Table 1126. Examples main() function.

DM script Note
Computes the factorial (series) of an integer with recursive and iterative methods.
Example

This script is to compute the factorial of an integer with recursive and iterative methods

Lines 10 to 16: Recursive version

Line 13: "return (1)" has the same function as "return 1"

Lines 18 to 24: Iterative version

Line 31: use the recursive version above

Line 33: use the use iterative version version above

void main () cannot be moved to the top of the script because the two functions, EMfactr() and EMfact(), have to be declared before they are called and used by main()

 

 

 

=================================================================================