Вы находитесь на странице: 1из 4

DATA TYPES IN C

A C language programmer has to tell the system before-hand, the type of numbers or characters he is using in his program. These are data types. There are many data types in C language. A C programmer has to use appropriate data type as per his requirement.Data types are the means to identify the type of data and associated operations to handle it. Data types are of 2 types. 1)Fundumental Data types
1. Integer ( int)

2. Character ( char) 3.Floating Point (float) 4. Double precision floating point (double) 2) Derived Data types 2.1) Built in data types 1.Array 2. pointer 3. function 2.2)User defined data type 1. Enumeration 2.structure 3.union Fundumental Data Types 1.Integer Type : Integers are whole numbers with a machine dependent range of values. A good programming language as to support the programmer by giving a control on a range of numbers and storage space. C has 3 classes of integer storage namely short int, int and long int. All of these data types have signed and unsigned forms. A short int requires half the space than normal integer values. Unsigned numbers are always positive and consume all the bits for the magnitude of the number. The long and unsigned integers are used to declare a longer range of values. eg: int a;

Floating Point Types : Floating point number represents a real number with 6 digits precision. Floating point numbers are denoted by the keyword float. When the accuracy of the floating point number is insufficient, we can use the double to define the number. The double is same as float but with longer precision. To extend the precision further we can use long double which consumes 80 bits of memory space. Eg: Float a; Character Type : A single character can be defined as a defined as a character type of data. Characters are usually stored in 8 bits of internal storage. The qualifier signed or unsigned can be explicitly applied to char. While unsigned characters have values between 0 and 255, signed characters have values from 128 to 127. eg: char k; Double Type The data type double is also used for handling floating point numbers.but it is treated as distinct data type because it occupies twice as much as memory as type float,and stores floating point numbers with much larger range and precision. The double data type is larger and slower than type float. Eg: double d;

Void type: This specifies an empty set of values.This is used with functions that do not return any value.

RANGE OF VALUES of data types char (-128 to 127) Int (-32768 to +32767 ) float ( 3.4 e-38 to 3.4 e+38) double (1.7 e-308 to 1.7 e+308) Derived Datatypes Array An array type describes a contiguously allocated nonempty set of objects with a particular member object type, called the element type. Array types are characterized by their element type and by the number of elements in the array. An array type is said to be derived from its element type, and if its element type is T, the array type is sometimes called array of T. The construction of an array type from an element type is called array type derivation. . Pointer A pointer type may be derived from a function type, an object type, or an incomplete type, called the referenced type. A pointer type describes an object whose value provides a reference to an entity of the referenced type. A pointer type derived from the referenced type T is sometimes called pointer to T. The construction of a pointer type from a referenced type is called pointer type derivation.

Function A function is a named part of a program that can be invoked from other part of the program as often needed. Enumeration

An Enum (short for Enumerated) variable type is a special flavor of a Long type variable. With an Enum, you can specify a number of valid values for that variable and descriptive constant names for the values of the Enum. These values are used instead of constants. Eg: enum{START,PAUSE,HOO}; This is similar to , const int START=0; const int PAUSE=1; const int HOO=3; Structure A structure type describes a sequentially allocated nonempty set of member objects (and, in certain circumstances, an incomplete array), each of which has an optionally specified name and possibly distinct type. Union A union type describes an overlapping nonempty set of member objects, each of which has an optionally specified name and possibly distinct type

Вам также может понравиться