Experiment 07 Function Dr. rer.nat. Jing LU
Goal How to define and call a function? How to write a function? What is the parameter in a function? What is the return value? How to use local parameter and global parameter? How to debug a function?
Practice 01 Input two integers, output the sum of the two integers, implement it using function;
Practice 02 Input some positive integers, ending with 0. Calculate the sum of all odd numbers. Implement it in function.
Practice 03 Input the coordinates of two points (x1,y1) and (x2, y2) in the plane surface. Calculate the distance of the two points. Use function distance (x1,y1,x2,y2).
Practice 04 Input an integer, output the factorial. Use function.
Result and Analysis Why we want a function? How is your conclusion of using a function? Advantages and disadvantages.