Data Types in C

                     C language has some predefined set of data types to handle various kinds of data that we use in our program.

                C data types can be classifies into 3 categories. 

These are :   1. Primary Data Types

                    2. Derived Data Types

                    3. User Defined Data Types

1.Primary Data Types:

                    All C compiler supports 4 fundamental data types. Namely int, char, float and double.

        1.1.int:    

                It is positive, negative and whole values but not a decimal number.

                Eg: 10, 20, 45, -30, 0 etc.

        1.2.char:  

                A single character can be treated as character data type and it is defined between single quotation marks.

                Eg: 'r', 'H', '5', '*', etc.

                Note: String is also a character data type. A group of characters defined between double quotation marks is a String.

                Eg: "HHHH", "abc123",  "123*/-+&", etc.,

        1.3.float: 

                The numbers which are stored in the form of floating point representation is called as float data type.

                Eg: 10.25, 478.1234, -82.74923 etc.

        1.4.double:

                The numbers which are stored in the form of double precision floating point representation is called as double data type.

                Eg: 1023.56789, 12345.3675, 0.456321, -567.4564 etc.

        Note:         void: Empty Data type.

2.Derived Data Types:

                These data types are created from the basic integers, characters and floating data types.

                Eg: arrays, pointers, structures etc.

3.User Defined Data Types:

                The user  defined data types enable a program to invent his own data types and defines what values it can taken.

                C supports 2 types of user defined data types.

                1. typedef (type definition)

                2. enum (enumurated data type)




Previous Topic :  C Tokens

No comments:

Post a Comment