You are on page 1of 3

Keth Iralex Cabalda BES 043

COC-FA-BSCE2-04 Module #18

Writing Functions

Activity 1: What I Know Chart

1. Was the main() body of a program called a function also?


- Yes.

2. Is a C++ function the same with a sub-program?


- Yes it is the same.

3. Where to write my created function, inside the main() function?


- Below the main function.

Activity 3: Skill-building Activities


Trace the output of the program.

1. Write a function for setting a number randomly chosen from the range of 1 to n, where n is the
parameter of the function. Its return type will be the generated number.
-
2. Write a function that will provide the time consumed with reference to the start time and stop time
value to receive. (Refer to topic 27 for the clock function).

Activity 5: Check for understanding,


Identify the parts of the function definition. How many parameter identifier(s) is/are declared?

1. Body of function

2. Type of values the function return

3. Names of function

4. Type of value the function requires the caller to provide.

5. The identifier that the function uses for the value received.
Activity 6: Thinking about Learning

Three things you learned:


1. identify the parts of the function.
2. I learned about functions.
3. I learned how to write customized functions.

Two things that you’d like to learn more about:


1. More about writing function.
2. More examples in writing program using function.

One question you still have:


1. Do we always put the function definition above the main program?

You might also like