The document provides instructions for a programming fundamentals laboratory task involving program control structures like if/switch statements and loops. It includes 3 questions to write programs that: 1) calculate sum and average of user-inputted numbers using loops, 2) print multiplication tables from 1-12 for a user-input number using loops, and 3) print a specified number of stars in rows using loops and cout.
The document provides instructions for a programming fundamentals laboratory task involving program control structures like if/switch statements and loops. It includes 3 questions to write programs that: 1) calculate sum and average of user-inputted numbers using loops, 2) print multiplication tables from 1-12 for a user-input number using loops, and 3) print a specified number of stars in rows using loops and cout.
The document provides instructions for a programming fundamentals laboratory task involving program control structures like if/switch statements and loops. It includes 3 questions to write programs that: 1) calculate sum and average of user-inputted numbers using loops, 2) print multiplication tables from 1-12 for a user-input number using loops, and 3) print a specified number of stars in rows using loops and cout.
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 :