Presentation is loading. Please wait.

Presentation is loading. Please wait.

 Data Type is a basic classification which identifies different types of data.  Data Types helps in: › Determining the possible values of a variable.

Similar presentations


Presentation on theme: " Data Type is a basic classification which identifies different types of data.  Data Types helps in: › Determining the possible values of a variable."— Presentation transcript:

1

2  Data Type is a basic classification which identifies different types of data.  Data Types helps in: › Determining the possible values of a variable › Possible operations which can be executed on the type › Meaning of the data › Different ways to store the data  Data Types are of different types: Primitive data Types Composite Data Types

3 › Primitive data types are those data types which are not defined in terms of other data types. Examples are: Integer Floating Point Boolean Character

4  Integers are used to hold integer values only.  This is further categorized into: byte short int long signed Unsigned Examples are: unsigned int x = 21234; unsigned int y = 31234; unsigned int z; z = x + y;

5  This data type contains decimal points.  Examples are: float f = 20.0 / 3.0;

6  Boolean Data type is used to store logical value.  It can have either True or False value.  It is a one bit representation › 0 represents false value › 1 represents true value › Example: Boolean a; › a=true;

7  Roman alphabet, punctuation, digits, and other symbols: › Can encode within one byte (256 symbols)  In C: char a_char = ’a’; char newline_char = ’\n’; char tab_char = ’\t’; charbackslash_char = ’\\’;

8  These data types are derived from more than one primitive data type.  Examples are: Arrays Records Structure Union

9  Arrays are a finite sequence of variables of the same data type These are commonly implemented by the compiler generating array descriptors for each array here we have descriptors for 1-D and multi-D arrays

10  Records are Varied aggregate of data elements › The elements of a record are known as fields or members › Records were introduced in COBOL › This data type is used in many languages. › In Java, the functionality of records are achieved through the use of classes Examples: COBOL (nested structure in one definition) 01 EMPLOYEE-RECORD. 02 EMPLOYEE-NAME. 05 FIRST PICTURE IS X(10). 05 MIDDLE PICTURE IS X(10). 05 LAST PICTURE IS X(20). 02 HOURLY-RATE PICTURE IS 99V99.

11  Types which can store different types of variables at different times of execution at the same memory location. › Example:  Integer X Real Y Equivalence (X, Y)  declares one memory location for both X and Y  the Equivalence statement is not a type, it just commands the compiler to share the same memory location  Other languages have union types › the type defines same or common location for two variables of different types

12  Used for indirect addressing for dynamic memory › dynamic memory when allocated, does not have a name, so these are unnamed or anonymous variables and can only be accessed through a pointer  Pointers store memory locations or null › usually null is a special value so that pointers can be implemented as special types of int values  By making pointers a specific type, some static allocation is possible › the pointer itself can be allocated at compile- time, and uses of the pointer can be type checked at compile-time int *, float *, char * – used to denote a pointer type, which is a memory address type

13


Download ppt " Data Type is a basic classification which identifies different types of data.  Data Types helps in: › Determining the possible values of a variable."

Similar presentations


Ads by Google