lecture_03 - Data structures and algorithms Expression Institute of Technology of Cambodia Electrical and Energy Engineering Department Contents \u2022

lecture_03 - Data structures and algorithms Expression...

This preview shows page 1 - 9 out of 28 pages.

Data structures and algorithms Institute of Technology of Cambodia Electrical and Energy Engineering Department Expression
Contents Data Types Operations
Data types Data types in C refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted. Introduction
Data type (cont.) Basic Types : integer, real, character, enumerate,… Structure type: struct, union… Pointer type
Declaration The general format for a declaration is type variable_name [= value] Example: char x ; /*uninitialized*/ char x=’A’; / intialized to ’A’ / char x=’A’,y=’B’; / multiple variables initialized / char x=y=’Z’; / multiple initializations /
Integer types Type Keyword Size (byte) Value range Character char 1 byte -128 to 127 Unsigned character unsigned char 1 byte 0 to 255 Integer int 2 byte -32,768 to 32,767 Unsigned integer unsigned int 2 byte 0 to 65,535 Short integer short 2 byte -32,768 to 32,767 Unsigned short integer unsigned short 2 byte 0 to 65,535 Long integer long 4 byte -2,147,483,648 to 2,147,483,647 Unsigned long integer unsigned long 4 byte 0 to 4,294,967,295