Professional Documents
Culture Documents
LAB SHEET 2
Computer Programming Basics
NG:YING KHIAN
NAME
_________________________________
(MARKS)
130220
MATRICS NO.:AD
_______________
_________
DATE
:
9/3/2015
Objectives:
Learn to write pseudo code
Learn to draw flow chart
Question 1
a) The purpose of the program is to print Welcoming text on screen when the program is
run.
Variablesdo not have any variables in this program
Inputdo not required any input for this program
Outputdisplay a welcome text on screen by preprocessor directives printf (_____)
; Punctuation
\n new line
b) /* The purpose of the program is to print text on screen when run.*/
#define MESSAGE Welcome to this computer programming class!\n
main( )
Predefine
printf(MESSAGE);
}
Ne
w
line
Output
c) main( )
{
\\ Declarations of Variables
\\ Statements
printf(Gross salary: );
scanf(%f, &gross);
\\ Input
tax = 0.14*gross;
net = gross tax;
printf(Taxes withheld: %.2f\n, tax); \\Output
Question 2
i) Flow chart
Start
Set
a= Bus
b= own transport
c= by walking
a= Bus
b= own transport
c= by walking
3. Input a or b or c
4. Print output
5. Ends
If a
If b
Display
By bus
Display
Own Transport
If c then Display
By walking
End
Question 3
Start
Calculate i=r/100
f= p*pow((1+i),n)
End