Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

FACULTY OF ELECTRICAL ENGINEERING TECHNOLOGY

UNIVERSITI MALAYSIA PERLIS

EMT30105
INDUSTRIAL MACHINERY CONTROL SYSTEM DESIGN

SEMESTER 1, ACADEMIC SESSION 2021/2022

RY88 – B. TECH ELECTRICAL ENGINEERING TECHNOLOGY


SYSTEM MAINTENANCE

LAB ASSESSMENT 1

NAME : HAFIZ ZIKRI BIN NORIZAN


MATRIC NO. : 191492857
COURSE : ELECTRICAL SYSTEM MAINTENANCE (RY 88)
LECTURE : DR. MUZAIDI BIN OTHMAN @ MARZUKI
LAB ASSESSMENT
TASK 1:
Question
Write the full program of the following statement. Then, rewrite it as an equivalent C
programming coding using switch statement to display the iValue. The variable digit is of type
int.
if (iDigit == 0)
iValue = 3;
else if (iDigit == 1)
iValue = 4;
else if (iDigit == 2)
iValue = 6;
else if (iDigit == 3)
iValue = 9;

Answer
a) The variable digit
1. idigit
2. ivalue

b) Pseudo Code

Figure 1: Pseudo Code for Switch Statement


c) Flow Chart

Start

Switch number

break
yes statement
Case number 0 Statement
idigit=0 ivalue=3

false
break
yes statement
Case number 1 Statement
idigit=1 ivalue=4

false
break
yes
Case number 2 Statement statement
idigit=2 ivalue=6

false
break
yes
statement
Case number 3 Statement
idigit=3 ivalue=9

false

Default action(s)
“Sila Cuba Sekali Lagi”

End

Figure 2: Flowchart for Task 1


d) C Program Run

Figure 3: Example idigit for 0 value

1. Insert the idigit 0 and display shows ivalue = 3.


2. Repeat the step 1, insert value idigit for 1,2 & 3.
3. Build and run again for show other ivalue such as 4, 6 & 9.

Figure 4: Display show for default value

1. If insert different / wrong idigit, the display will show default “Harap Maaf, Sila Cuba
Sekali Lagi”.
TASK 2
Write a program that determines Ali’s total mark according to the percentage of coursework
below. Provide the flowchart and write down your program.

a) The variable
1. T1 (Test 1)
2. T2 (Test 2)
3. LA (Lab Assessment)
4. Proj (Project)

b) Pseudo Code

Figure 5: Pseudo Code for Task 2

c) C Program Run

Figure 6: Display program for Task 2


d) Flowchart

Start

Define the float for T1, T2, LA, Project

T1 = 30% (0.15)
T2 = 25% (0.25)
LA = 30% (0.3)
Project = 30% (0.3)

Print Total

End

Figure 7: Flowchart for Task 2


TASK 3
a. Analysed this program and determine the output. Then make a change to the
program to display the output of 1 3 5 7 9 11 13 15 17 19.

 The false program and cannot display any output value.

Figure 8: Wrong program

 The true for this program

Figure 9: True program


b. Analysed this program and determine the output. Then make a change to the
program to display the output of 2 5 8 11 14 17 20.

 The false program and display the incorrect output value.

Figure 10: Incorrect program

 The true programme

Figure 11: True program


TASK 4
Write a program to print whether a given number is even or odd. (hint: use if else if statement
and used a modulus operator to determine the remainder).

a) Pseudo Code

Figure 12: Pseudo Code for Number Even and Odd


b) C Program Run

Figure 13: Display C Program for Odd Number

1. If insert odd number like number 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 and etc odd number.
2. Run the number from step 1, the display will identify odd number.

Figure 14: Display C Program for Even Number

1. If insert odd number like number 2, 6, 8, 12, 14, 18, 20 and etc even number.
2. Run the number from step 1, the display will identify even number.

You might also like