Laboratory 4 Part 1 - Developing Programs Using Functions
Laboratory 4 Part 1 - Developing Programs Using Functions
COMPUTER PROGRAMMING
BTIG 1213
SEMESTER 2
SESSION 2011/2012
DATE
NAME OF GROUP MEMBERS
& MATRIX NUMBER
1.
2.
3.
NAME OF INSTRUCTORS
1.
2.
3.
EXAMINERS COMMENTS
VERIFICATION STAMP
TOTAL MARKS
Document Number
N/A
Revision Number
1.0 (sulaiman)
Issue Number
29.02.2012
Total Pages
1.0
LEARNING OUTCOMES
1. To apply function technique in the program development in C++ programming.
2. To apply function call and function with returning value
3. To identify error and troubleshoot a C++ program
2.0
EQUIPMENTS
1. Personal Computer
2. 'DEV C++' or 'Microsoft Visual C++ 2010 Express Edition' installed.
3.0
Type of function;
Pre-defined (or Standard) Function
User-defined Function
Pre-defined (or Standard) Function
Example :mathematical functions in <cmath> (called cmath header file) are:
The power function, pow(x,y), The square root function, sqrt(x), The floor function, floor(x)
etc.
User-defined Function
It has three parts:
Function declaration - is done first with a prototype declaration.
Function definition - contains the code to complete the task.
Function call (or invocation) - to call function to perform its task.
To use this type of function, the programmer has to call (or invoke) the function. But the
function must first be declared and defined before it can be used.
Please refer to lecture slides for more details about the how to write function declaration,
function call and function definition.
This lab we will investigate some application C++ programming which is applying various
types of function in the program development process, include function with and without
parameter, with and without return value.
4.0
PROCEDURE
You need to complete this procedure during your 3 hours labs.
7. Now, you need to modify the program 4.2 to get the correct answer. Write down
your code in your report.
[7 marks]
[1 marks]
14. Now, you need to modify the program 4.2 to get the correct answer. Write down
your code in your report.
[7 marks]