02 01 Data and Data Types
02 01 Data and Data Types
Procedural Programming
Procedural Programming 2
Please see this material first
Procedural Programming 3
Outlines
Procedural Programming 4
Data types in C
Procedural Programming 6
Primitives data types
• Signed or unsigned?
• Signed accepts both positive and negative values.
• Unsigned accepts only positives.
Procedural Programming 7
char
char c1 = 'a';
char c2 = 98;
printf("c1: %c (%hhu); c2: %c (%hhu).\n", c1, c1, c2, c2);
Procedural Programming 8
Integer family
int i = -32;
short int si = 49;
unsigned long l = 98;
long long ll = 198203;
printf("i: %hi; si: %hi; l: %lu; ll: %lli.\n", i, si, l, ll);
Procedural Programming 9
Floating-point data types
float f = -32.61;
double d = 98.76;
long double ld = 63126.115115115;
printf("f: %f; d: %lf; ld: %Lg.\n", f, d, ld);
Procedural Programming 10
Composite data types
• Multi-valued: array.
• It can hold multiple homogenous type of values.
• In the memory, the values are stored sequentially.
• Each value is accessible through the index (0-based).
• Record/structure.
• It is able to hold multiple values.
• It allows heterogeneous type of values.
Procedural Programming 11
Other data types
• Enumeration.
• Integer-based labels.
• Pointer.
• Represents memory location depends
on the CPU architecture 32-bit or 64-bit.
• void.
• Simply ‘nothing’.
Procedural Programming 12
Boolean?
Procedural Programming 13
String?
Procedural Programming 14
Todos
Procedural Programming 15
References
Procedural Programming 16
Thank
you
Procedural Programming 17