LAB ACTIVITY 2: BASIC C++ PROGRAM
Duration: 2 Hours
Learning Outcomes
This lab activity encompasses activities 2A, 2C, and 2E
By the end of this practical session, you should be able to :
• Declare variables
• Use input output statements
• Apply operators and expression
Hardware/Software: C++ software (Microsoft Visual Studio, Turbo C++ 5.0/6.0)
SCENARIO:
Congratulations to you!!
You have impressed Miss Suria on your capability to solve the task handed to you in Activity 1.
Therefore, Infinity Design Solution Sdn. Bhd, with the supervision of Miss Suria has given you the task to
help Finance Unit in completing payroll system. The scenario is that; In January of each year, Infinity
Design Solution Sdn. Bhd pays a 5% bonus to each of its salespeople. The bonus is based on the amount
of sales made by the sales person during the previous year.
INSTRUCTION:
Before you continue to write codes in C++, Miss Suria gives you some exercises. Complete the exercises
below and follow the process in completing your codes.
Activity 2A
Activity Outcome: Declare variables
Duration : 10 minutes
Task 1: Fill in the blanks with the correct answer.
a)
Type Description
bool
Typically a single octet(one byte). This is an integer type.
int
A single-precision floating point value.
double
Represents the absence of type.
wchar_t
b)
Type Variable List Valid Declaration
int i,j,k
char c,ch
float f,salary
double d
Activity 2C
Activity Outcome: Apply operators and expression
Duration : 10 minutes
Task 3 : Identify and match the types of operator with their example correctly.
Types of Examples
operator
Arithmetic Operators (A & B) will give 12
which is 0000 1100
Relational Operators
A++ will give 11
C *= A is equivalent
Logical Operators
to C = C * A
Bitwise Operators (A && B) is false.
Assignment
(A == B) is not true.
Operators
Activity 2E.1
Activity Outcome: Identify input, process and output
Duration : 10 minutes
Task 1: You must identify the input, process and output from the given task in Case Study.
INPUT PROCESS OUTPUT
Activity 2E.2
Activity Outcome: Constructing Flowchart
Duration : 10 minutes
Task 1: Construct a flowchart of the given task based on 2E.1.
Flowchart
Activity 2E.3
Activity Outcome: Constructing Pseudocode
Duration : 10 minutes
Task 1: Construct a pseudocode of the given task based on 2E.2.
Pseudocode
Activity 2E.4
Activity Outcome: Write a program code
Duration : 30 minutes
Task 1: Write a complete code of the given task based on 2E.3. Then, compile the program using C++
and write the output.
Output