Search

DATA TYPES

 "Data types specifies the type and size of data . "

A program contains different types of data (integer , real , character etc.)  and need to store values being used in the program . C++ language is rich of data types . 

It is divided into three types ------------------

  1. Primary data types 
  2. Derived data types 
  3. User Defined data types

Data Type

Size (in bytes)

Range

short int

2

-32,768 to 32,767

unsigned short int

2

0 to 65,535

unsigned int

4

0 to 4,294,967,295

int

4

-2,147,483,648 to 2,147,483,647

long int

4

-2,147,483,648 to 2,147,483,647

unsigned long int

4

0 to 4,294,967,295

long long int

8

-(2^63) to (2^63)-1

unsigned long long int

8

0 to 18,446,744,073,709,551,615

signed char

1

-128 to 127

unsigned char

1

0 to 255

float

4

 

double

8

 

long double

12

 

wchar_t

2 or 4

1 wide character




VARIABLE IN C++

A variable is a value that can change anytime . It is a memory location used to store a data value . variable name is case sensitive.
  1. They must always begin with a letter , although some system permit underscore as the first character.
  2. The length of a variable most not be more than 8 character.
  3. white space is not allowed .
  4. a variable should not be a keyword.
  5. it should not contain any special characters.

example of invalid variable names are :
 
123 , (area) , -hello , %abc , etc.

A variable must be declared before it can be used . Variables can be declared at the start of any block of code . 

constant in c++ language |

 " A constant value is the one which does not change during the execution of a program . "

constant uses a secondary storage area .

constant has fixed value .

constant in every language are the same .

in C++ language constant are of two types ___

  1. numeric constant
  2. non-numeric constant


Identifier in C++ |

 the name of a variable , function , class , or other entity in c++ is called an identifier.

rules :  

  •  The identifier can not be a keyword . Keywords are reserved .
  • The identifier can only be composed letters, number , and the underscore character . that means the name can not contains symbols nor whitespace .
  • The identifier must begin with a letter or an underscore . it can not start with a number ,
  • C++ distinguishes between lower and upper case letter . 



 


Keywords in C++ |

 Every words in C++ language is a keyword or an identifier . Keywords in C++ language can not be used as a variable name . They are specifically used by the compiler for its own purpose and they serve as   building blocks of a C++ program.

 C++ language has some reserve word which are called keywords. They are the part of the C++ tokens.

There are 63 keywords currently defined for standard C++. 


C++ Keyword

asmdoublenewswitch
autoelseoperatortemplate
breakenumprivatethis
caseexternprotectedthrow
catchfloatpublictry
charforregistertypedef
classfriendreturnunion
constgotoshortunsigned
continueifsignedvirtual
defaultinlinesizeofvoid
deleteintstaticvolatile 
dolongstruct
while 


  C++

DATA TYPES

 "Data types specifies the type and size of data . " A program contains different types of data (integer , real , character etc.) ...