Professional Documents
Culture Documents
PRACTICAL WORK 1 2 3 4 5 6
SUBMISSION DATE
GROUP MEMBERS REGISTRATION NUMBER
1.SARAHMEI BINTI ABDULLAH 17DTK20F2005
2.
3.
4,
PROGRAMME DEC
CLO 2P MALAYSIA
SULTAN IDRIS SHAH
1. To construct programs that uses simple if, if else, nested if else and switch statements
EQUIPMENTS :
1. Personal computer / Laptop
2. Dev-C++ software Lab 3.1 Conditional Structure
(if)
Procedures:
3.1.1 Write the following programming below and try to understand it.
print f ("I would like to get marks for DEC20012 subject", marks) ; system
("pause") ; return o;
Answers:
int marks; print f ( " What would be YOur targeted marks for DEC2C012
scanf &marks) ;
else { printf ("T should have set my sight higher for DEC20012.
. \n") ; } system ("pause") ; return 0 ; }
WORK
CLO 2P
MALAYSIA SULTAN
IDRIS SHAH Answers:
if {
printf ("You Passed In") ;
7 PSIS / JKE / DEC20012 PROGRAMMING FUNDAMENTALS / PRACTICAL WORK
MALAYSIA SULTAN
IDRIS SHAH
else if {
printf ("Moderate\n") ;
printf ("Y0u ;
system ("pause") ;
Answers:
DEC20012
9 PSIS / JKE / - PROGRAMMING FUNDAMENTALS / PRACTICAL WORK 31
CLO 2P
MALAYSIA
SULTAN IDRIS SHAH
Write a program that prompt and get two numbers, compare the two numbers
and display "They are equal" if .
ANSWER
DEC20012
10 PSIS / JKE / - PROGRAMMING FUNDAMENTALS / PRACTICAL WORK 31
CLO 2P
DEC20012
11 PSIS / JKE / - PROGRAMMING FUNDAMENTALS / PRACTICAL WORK 31
CLO 2P
MALAYSIA
SULTAN IDRIS SHAH
Alter the codes at Task A so that the program WI 11 display "nuttil is less
than nurn2" if (num1<num2) and "numl is greater than num2" if (num1>num2) .
DEC20012
12 PSIS / JKE / - PROGRAMMING FUNDAMENTALS / PRACTICAL WORK 31
CLO 2P
ANSWER
{ printf ("Keyboard
much?" ) getchar ( ) ; return O;
Output
a) If answer = Y
b) If answer = n
PRACTICAL WORK
CLO 2P
c) If answer = r
PRACTICAL WORK
Modify the program at Task C by using if else statement to get the same output Answer
int a=2;
if (a==2)
else
break;
A. if B. nested if else
C. if else D. switch
PRACTICAL WORK
CLO 2P
CLO 2P
Flowchart: (3 marks)
start
Body of loop
Condition
Stop
Display_the
_statement