4.16.24 21st Century Movements for Black Lives.pptx
Lab 6 sem ii_11_12
1. UNIVERSITI TUN HUSSEIN ONN MALAYSIA
FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING
BTI 10202: COMPUTER PROGRAMMING
LAB 6: Control Structure –Part 3
NAME : ______________________________________ MARK
MATRICS NO.: ____________________ DATE : ________
Objective: Students will be able to write C program using combinations of control structure
technique.
Exercise 1:
An institute offers a course that prepares students for the licensing exam for real brokers.
Last year, several of the students who completed this course took the licensing examination.
Naturally, the institute wants to know how well its students did on the exam. You have been
asked to write a program to summarize the results. You have been given a list of these 15
students. From the list of result the program should able to segregate between pass and fail.
Students with test result between 0-39 will be mark as failed while 40-100 mark as passed.
Your program should analyze the results of the exam as follow:
1. Input each test result (i.e. 20, 55). Display the message “Enter result <no>” on the
screen each time the program requests another test result.
2. Display a summary of the test results indicating the number of students who passed and
the number of students who failed.
3. If more than 6 students failed in the exam, print message “Need teaching
improvement!”
(Tips: pseudo-code given as following)
Declare result as floating number
Declare and Initialize pass to zero
Declare and Initialize fail to zero
Declare and Initialize student counter to one
While student counter is less than or equal to fifteen
Label reenter
Get result
If result is smaller and equal to 100 and result is larger and equal to 40
Add one to pass
Add one to student counter
1
2. Else if result is smaller than 40 and result is larger and equal to 0
Add one to fail
Add one to student counter
Else
go to label reenter
Print the number of pass
Print the number of fail`
If more than 6 students failed
Print “Need teaching improvement”
Re-write your program:
2