DATA TYPES DATA TYPES AND KEYWORDS l There

  • Slides: 13
Download presentation
DATA TYPES

DATA TYPES

DATA TYPES AND KEYWORDS l There are five elementary data types in C: character

DATA TYPES AND KEYWORDS l There are five elementary data types in C: character (char), integer (int), floating point, double floating point and void.

CHAR l Values of type char are used to hold ASCII characters or any

CHAR l Values of type char are used to hold ASCII characters or any 8 -bit quantity.

INT l Variables of type int are used to hold real numbers. Real numbers

INT l Variables of type int are used to hold real numbers. Real numbers have both an integer.

Float and Double l Values of type float and double are used to hold

Float and Double l Values of type float and double are used to hold real numbers. l Rea numbers have both an integer and fractional component.

Void l The type void has three uses: – To declare explicitly a function

Void l The type void has three uses: – To declare explicitly a function as returning no value. – To declare explicitly a function as having no parameters. – To create generic pointers.

Type char int float double void Bidwidth Range 8 16 32 64 0 0

Type char int float double void Bidwidth Range 8 16 32 64 0 0 to 255 -32768 to 32767 3. 4 X 10 -38 to 3. 4 X 1038 1. 7 x 10 -308 to 1. 7 x 10308 valueless

Type Modifiers l Except type void, the basic data types may have various modifiers

Type Modifiers l Except type void, the basic data types may have various modifiers preceding them. l A modifier is used to alter the meaning of the base type to fit the needs of various situations more precisely.

Type Modifiers l The list of modifiers includes the following: – Signed – Unsigned

Type Modifiers l The list of modifiers includes the following: – Signed – Unsigned – Long – Short

Type Bidwidth char unsigned char int unsigned int short int unsigned short int 8

Type Bidwidth char unsigned char int unsigned int short int unsigned short int 8 8 8 16 16 16 Range -128 to 127 0 to 255 -128 to 127 -32768 to 32767 0 to 65535 -32768 to 32767 0 to 655535

Type Bidwidth Signed short int Long int Unsigned long int Signed long int 16

Type Bidwidth Signed short int Long int Unsigned long int Signed long int 16 32 32 32 Float 32 Double 64 Long double 64 Range -32768 to 32767 -2147483648 to 2147483647 0 to 4294967295 -2147483648 to 2147483647 3. 4 x 10 -38 to 3. 4 x 1038 1. 7 x 10 -308 to 1. 7 x 10308

Keywords l Keywords in C are reserved words that have a special meaning. l

Keywords l Keywords in C are reserved words that have a special meaning. l Reserved words are words “reserved” by the programming language for expressing various statements and constructs, thus, these may not be redefined by the programmer.

Keywords l List of 32 Keywords / Reserved words as defined by the ANSI

Keywords l List of 32 Keywords / Reserved words as defined by the ANSI standard. auto break case char const continue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef union unsigned void volatile while