additional note - lab3 -cik syazana - Portal

jaspersugarlandΛογισμικό & κατασκευή λογ/κού

14 Δεκ 2013 (πριν από 3 χρόνια και 10 μήνες)

80 εμφανίσεις

PREPARED BY: CIK NOOR SYAZANA BT ARSHAD

Page
1


DATA TYPES



CHARACTER ( c )



Single character



Ex: A, z,2,9



Memory allocation: 1 byte



Declaration format

<data type> <variable name>

Ex: char cNameInitial;



printf
-

%c scanf
-

%s




ARRAY OF CHARACTER (ac)



A collection of characters



Ex: WGA5522



Memory
allocation: (depend on the number of character in an array)



Can be a letter or number or combination of both

letter and number



Declaration format

<data type> <variable name> [
subscript / index]

Ex: char acName[10];



printf
-

%s scanf
-

%s




INTEGER (i)



Real numbers

in range
-
32768 until 32767



Ex: 5, 10, 205



Memory allocation: 2 bytes



Declaration format


<data type> <variable name>



Ex: int iAge;



printf
-

%d scanf
-

%d



PREPARED BY: CIK NOOR SYAZANA BT ARSHAD

Page
2




LONG INTEGER (l)



Real numbers exceeds integer range



Ex: 5034678293



Memory allocation: 4 bytes



Declaration format


<data type> <variable name>



Ex: long int lPhoneNumber;



printf
-

%ld scanf
-

%ld




FLOAT (f)



Number in decimal places



Ex: 5.2, 0.3



Memory allocation: 4 bytes



Declaration format


<data type> <variable name>



Ex: float fArea;



printf
-

%f scanf
-

%f




DOUBLE (d)



Number in decimal places



Ex: 5.3214, 0.3885



Memory allocation: 8 bytes



Declaration format


<data type> <variable name>



Ex: double fArea;



printf
-

%f scanf
-

%lf









PREPARED BY: CIK NOOR SYAZANA BT ARSHAD

Page
3


EXPLAINATION ON LAB 3 QUESTION NO 2.6


PSEUDOCODE

Start


Read one input of five digit number


Divide the value by 10,000 and store as digit 1


Set the reminder equals to value


Divide the value
by 1,000 and store as digit 2


Set the reminder equals to value


Divide the value by 100 and store as digit 3


Set the reminder equals to value


Divide the value by 10 and store as digit 4


The reminder is store as digit 5


Print out Digit1, Digit2, Digit3
, Digit4 and Digit5

End













PREPARED BY: CIK NOOR SYAZANA BT ARSHAD

Page
4