You are on page 1of 5

Computer Programming

DAE20102 Instruction Sheet

Lab No. 5
Lab Title Repetition Structure (Problem Solving)
Semester 02
Session 2020/21
Lab Durations 3 Hours
Independent Studies 2 Hours
Computer Programming (DAE20102) ii
Lab 5

Table of Contents

1.0 Outcomes A 

2.0 Guidelines A 

3.0 Lab Activity B 

Lab Activity 1: Use the for loop B 

Lab Activity 2: Problem Solving C 

Questions 2 

Lab Activity 4 

Lab Activity 1 4 

Lab Activity 2 8 

Conclusion 11 

Grading Rubric for Written Reports 12 

CeDS, Semester 2 Session 2020/2021


Computer Programming (DAE20102) A
Lab 5: Repetition Structure (Problem Solving)

1.0 Outcomes

After completing this module, students should be able to:


1. Give response on how to use computer programming and presents the results of work
(CLO1, P3).
2. Systematically generate a computer program using a computer programming language to
solve a given problem (CLO2, C3).
3. Identify the ethical aspects of software development to be used by programmers (CLO3, A2).

2.0 Guidelines

1. Grouping: Lab group is predetermine and consists with at most two team members.
2. Registration: Students are required to register the course before attending the class.
3. Lab Activities: All lab activities such as lab assignments, questions and analysis must be
held in the respective lab location and completed within the given times.
4. Demonstration: Student must demonstrate the complete lab assignments to the respective
instructor. Verification only will be given upon completion of all lab activities and initialized by
the instructor on the respective page.
5. Report Organization: Report must be properly handwritten. Submit the lab report with
Arabic numerical reference only.
6. Conclusion: Must be measureable, term such as understand or learnt shall not be use as a
conclusion. Conclusion is a summary made from the observations and lab activities
which relate the theoretical aspect and implementations.
7. Report Submission: Report must be submitted at the end of each lab session to the
respective instructor.
8. Cover Page: Please fill in ALL the necessary information on the cover page. Two (2) marks
will be deducted for the each incomplete information.

CeDS, Semester 2 Session 2020/2021


Computer Programming (DAE20102) B
Lab 5: Repetition Structure (Problem Solving)

3.0 Lab Activity

Lab Activity 1: Use the for loop

1. Copy the following source code

/*Demo on for loop*/


#include <iostream>
using namespace std;
int main()
{
int x;
//Display Hello for n times
cout <<"How many you want to display this message? "<<endl;
cin >> n;
for (x=1; x<=n; x++){
cout<< x <<". Hello"<<endl;
}
return 0;
}

2. Observe and answers all the relevant questions.

CeDS, Semester 2 Session 2020/2021


Computer Programming (DAE20102) C
Lab 5: Repetition Structure (Problem Solving)

Lab Activity 2: Problem Solving

Suggest your solution for the following problem statement.


Write a C++ program that able to calculate the effective resistance of three resistors connected in
parallel. To ensure that the program able to perform the calculation, the value entered by a use
must be a correct value, which mean the input value must not zero, 0 and must a positive value.
Otherwise, the program displays a warning message and asks the user to re-enter resistor’s
value.

CeDS, Semester 2 Session 2020/2021

You might also like