0% found this document useful (4 votes)
1K views7 pages

DFC2037 - Lab Activity 2

This document outlines a lab activity on basic C++ programming. The activity is divided into multiple parts to help students declare variables, use input/output statements, apply operators and expressions, and write a program to calculate sales bonuses. The tasks include filling in code snippets, writing and compiling simple programs to print outputs, identifying programming concepts, and constructing a flowchart, pseudocode and full code for a bonus calculation program.

Uploaded by

sudersen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (4 votes)
1K views7 pages

DFC2037 - Lab Activity 2

This document outlines a lab activity on basic C++ programming. The activity is divided into multiple parts to help students declare variables, use input/output statements, apply operators and expressions, and write a program to calculate sales bonuses. The tasks include filling in code snippets, writing and compiling simple programs to print outputs, identifying programming concepts, and constructing a flowchart, pseudocode and full code for a bonus calculation program.

Uploaded by

sudersen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

DFC 2073 PROGRAMMING FUNDAMENTALS

LAB ACTIVITY 2: BASIC C++ PROGRAM

Duration: 2 Hours

Learning Outcomes
This lab activity encompasses activities 2A, 2B, 2C, 2D 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.

0|Page
DFC 2073 PROGRAMMING FUNDAMENTALS

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 2B
Activity Outcome: Write and compile a program using C++.
Duration : 20 minutes

Task 2 : Follow the procedure below step by step.

PROCEDURE OUTPUT
Program 1:

Step 1: Type the programs given below

1|Page
DFC 2073 PROGRAMMING FUNDAMENTALS

Step 2: Compile the program.


Step 3: Write the output.

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 operator Examples

(A & B) will give 12


Arithmetic Operators
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

2|Page
DFC 2073 PROGRAMMING FUNDAMENTALS

Activity 2D
Activity Outcome: Apply operators and expression
Duration : 20 minutes

Task 4 : Follow the procedure below step by step.

PROCEDURE OUTPUT
Program 1:

Step 1: Type the programs given below

Step 2: Compile the program.


Step 3: Write the output.

3|Page
DFC 2073 PROGRAMMING FUNDAMENTALS

Program 2:

Step 1: Type the programs given below

Step 2: Compile the program.


Step 3: Write the output.

Activity 2E.1
4|Page
DFC 2073 PROGRAMMING FUNDAMENTALS

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

5|Page
DFC 2073 PROGRAMMING FUNDAMENTALS

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
Output

6|Page

You might also like