Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

DEPARTMENT OF INFORMATION TECHNOLOGY & COMMUNICATION

DFC20113 – PROGRAMMING FUNDAMENTALS


LABORATORY TASK 3:
PROGRAM CONTROL STRUCTURES

Learning Outcomes

By the end of this lab, student should be able to:


 Describe the structure of if and switch statement
 Explain the need of break statements
 Write program using selection and repetition control structures

QUESTION 1 (10 MARKS)


Gunakan loop  untuk membuat program yang dapat mencari jumlah dan purata nombor  yang
dimasukkan. Contoh interaksi seperti berikut :
        
Masukkan Nombor ke-1 : 3
            Mau memasukkan data lagi [y/t] ? y
            Masukkan Nombor ke-2 : 5
            Mau memasukkan data lagi [y/t] ? t
            
Jumlah Nombor = 8
Purata = 4

QUESTION 2 (10 MARKS)


By using loops statement, print a series of tables from the range 1 to 12 for a number key in by users.
Example of output:

Please input one number integer : 5


SIFIR 5
1x5=5
2 x 5 = 10
3 x 5 = 15
4 x 5 = 20
5 x 5 = 25
6 x 5 = 30
7 x 5 = 35
8 x 5 = 40
9 x 5 = 45
10 x 5 = 50
11 x 5 = 55
12 x 5 = 60
TAMAT SIFIR 5

QUESTION 3 (10 MARKS)


By using loops statement, write a program to print output as below :

Key in how many star do you want to produce: 5


The output…

*****
*****
*****
*****
*****

Use cout<<”*”;

1|Page

You might also like