0% found this document useful (0 votes)
272 views15 pages

Format Dec20012 PKK Practical Work 4 Practical Work Finalize

1. The document outlines a practical work session on programming fundamentals for an electrical engineering course. 2. It provides instructions for students to complete assignments on looping statements in C involving break, continue, and goto statements. 3. The assignments include fixing errors, writing programs to display outputs, and modifying programs using combinations of control statements. Students are assessed on their practical skills and must submit a report.

Uploaded by

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

Format Dec20012 PKK Practical Work 4 Practical Work Finalize

1. The document outlines a practical work session on programming fundamentals for an electrical engineering course. 2. It provides instructions for students to complete assignments on looping statements in C involving break, continue, and goto statements. 3. The assignments include fixing errors, writing programs to display outputs, and modifying programs using combinations of control statements. Students are assessed on their practical skills and must submit a report.

Uploaded by

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

ELECTRICAL ENGINEERING DEPARTMENT

ACADEMIC SESSION: _____________

DEC20012: PROGRAMMING FUNDAMENTALS

Build programs written in C language for assigned mini project during practical
CLO2
work session ( P4 , PLO 5 )
PRACTICAL WORK 4 : Looping Statements Part 2
PRACTICAL WORK DATE :
LECTURER’S NAME:

NAME :
TOTAL MARKS
STUDENT ID :

1. Fixes
2. Complete
3. Manipulates
Practical Skill 4. Builds
Assessment 5. Display
[CLO2] 6. Lab Particaipation
7. Efficiently
Total Practical Skill Assessment
A. Total Practical Skill Assessment (80%) = /35 *80
1. Theory
Report 2. Discussion
Assessment 3. Conclusion
Total Report Assessment
B. Total Report Assessment (20%) = /15*20
Total A+B (100%)
DATE SUBMIT : DATE RETURN :
1 LEARNING OUTCOMES (LO):
1. Understand looping statements.
2. Apply looping statements.
2 OBJECTIVE
1. To fixes, Complete and Manipulates the Looping Statement combine with Break, Continue and
Goto statement.
2. To builds flowchart of Looping Statement combine with Break, Continue and Goto statement.
3. To display the output of Looping Statement combine with Break, Continue and Goto statement
3 THEORY
1. Looping Statements as a control statement operation.
2. FOR, WHILE, and DO-WHILE statements
3.BREAK, CONTINUE AND GOTO statements
4 EQUIPMENT / TOOLS
Computer, C programming language ( Dev-cpp, codeblock, dll)
Preparation before Practical Work 4 (Independent Learning (NF2F):
[Student should be prepare before Lab Session]
Define continue statements.
Answer:

Syntax of continue statement in C Flow chart diagram to represent continue operation

Answer: Answer:

Define break statements.


Answer:

Syntax of break statement in C Flow chart diagram to represent break operation

Answer: Answer:
Define goto statements.
Answer:

Syntax of goto statement in C Flow chart diagram to represent goto operation

Answer: Answer:

Lecturer Verification & Approval,

(Sign & cop)


Date :
Practical Work Task (Depended Learning (F2F)):
[Student should be complete all ]
Program : Practical Assignments 01
Fixes the error in the program below and then compile to get the output.

#include <stdio.n>
int main()
{
int num = 10:
while (num > 0)
{
if (num = 5)
break;
printf("%f\n" num);
--num;
}
}
Answer (Fixed program):

Output : Practical Assignments 01


Answer (Output):
Flowchart : Practical Assignments 01
Answer (Flowchart):

Lecturer Verification & Approval,

(Sign & cop)


Date :
Program :Practical Assignments 02
Compile the program below and trace the output.
#include <stdio.h>
int main()
{
int nb = 7;
while (nb > 0)
{
nb--;
printf("%d\n", nb);
}
}
Output for practical assignment 02:
Answer (ouput):

Modified the program in Practical Assignments 02 using combination of if and continue statement to eliminate
ONLY number 3 in the sequence of number at output display.

6
5
4
2
1
0

Answer (Modified program):


Program : Practical Assignments 03
Write a program to enter a numbers and the entered numbers will be added continuously until STOPPED when
certain value (as a termination code) is selected to terminate the process. Use the GOTO statement combined with
the other related control statement to build the program. (Hint: termination code : 999 or can use any value)

Answer Flowchart : Practical Assignments 03

Answer Program in Practical Assignments 03:


Answer Output display in Practical Assignments 03

Lecturer Verification & Approval,

(Sign & cop)


Date :
Program :Practical Assignments 04

Complete the table below with the CORRECT value Program Practical Assignment 04
of sum and I based on program given

#include <stdio.h>
Table 1: The expected value sum and i for looping int main()
cycle in the C program practical assignment 04 {
int sum=0;
Value of sum Value of i int i;
0 0 for(int i = 0; i<=15; i++)
{
sum = sum+i;
if(i==10)
{
goto addition;
}
}

addition:
printf("%d", sum);

return 0;
What is the value i to becomes the program stop
}
and terminate the loop statement?
i =___________

Fill your answer in the space given.

Based on the C program given above (program practical assignment 04) manipulates these code to produce the
flowchart and display the output to represent it operation.

Answer Flowchart : Practical Assignments 04


Answer Output display in Practical Assignments 04:

Explain how the operation of these program clearly.


Answer:

Lecturer Verification & Approval,

(Sign & cop)


Date :
Practical Exercise 1
Manipulates Program 1: What is the output for the C statement below?. Based on that program build the related
flowchart that represent its operation.

Program 1
Answer flowchart:
Explanation: Give your explanation based on program given how do…while statement done its operation in the
program.
Answer explanation:

Answer (Output display):

Lecturer Verification & Approval,

(Sign & cop)


Date :
Practical Exercise 2
Manipulates Program 2: Consider the program code below. What is the output result? Explain your result why it
is not as expected. Modify the program to meet the requirement.

Answer 1 (Output):
Answer 2 (Explanation):

Answer 3 (Modify program):

Lecturer Verification & Approval,

(Sign & cop)


Date :

Discussion :
Conclusion :

Lecturer Verification & Approval,

(Sign & cop)


Date :

You might also like