5
DATA TYPES IN C PROGRAMMING •In the C programming language, data types 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. •A Data Type is used to: –Identify the type of a variable when the variable is declared –Identify the type of the return value of a function –Identify the type of a parameter expected by a function

C PROGRAMMING ESSENTIALS

Embed Size (px)

Citation preview

Page 1: C PROGRAMMING ESSENTIALS

DATA TYPES INC PROGRAMMING

• In the C programming language, data types 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.

• A Data Type is used to:–Identify the type of a variable when the variable is declared–Identify the type of the return value of a function–Identify the type of a parameter expected by a function

Page 2: C PROGRAMMING ESSENTIALS

CLASSIFICATION OF

DATA TYPES INC PROGRAMMINGThe data types in C can be classified as follows:

Type

Basic typesThe C language provides many basic types. Most of them are formed from one of the four basic arithmetic type specifiers in C (char, int,float and double), and optional specifiers (signed, unsigned, short, long).A composite data type is any data type which can be constructed in a program using the programming language's primitive data types and other composite types. The act of constructing a composite type is known as composition.

Page 3: C PROGRAMMING ESSENTIALS

DETAIL ABOUT PRIMARY DATA TYPES•INTEGER

• These are whole numbers,both positive and negative.Unsigned integers(positive values only)are supported.

• In addition,there are short and long integers.The keyword used to define integers is,int.• C has three classes of integer storage,namely short int,int and long int,in both signed and

unsigned forms.• For 16 bit machine,the range of signed integer numbers will be from -32,768 to

32,767,and for unsigned integer numbers will be from 0 to 65,535.• The table shows combinations of basic types (or qualifiers),length in bits,and its range.

Page 4: C PROGRAMMING ESSENTIALS

CHARACTERA single character can be defined as a character data type.The keyword used to define character variable is char.Characters are usually stored in 8 bits(1 byte) of internal storage.Signed characters use all the bits for both magnitudes of number and sign are always negative or positive,whereas unsigned characters use all bits for the magnitude of number and are always positive.The table shows combinations of basic types(or qualifiers),length in bits,and its range.

TYPE LENGTH RANGEunsigned int 16 bits 0 to 65,535Short int 16 bits -32,768 to 32,767Int 16 bits -32,768 to 32,767Unsigned long 32 bits 0 to 4,294,967,295Long 32 bits -2,147,483,648 to

2,147,483,647

Page 5: C PROGRAMMING ESSENTIALS