c++ primitive types code example

Example 1: range of long long in c++

Long
Data Type	          Size             (in bytes)	Range
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

Example 2: data types in c++

int myNum = 5;               // Integer (whole number)
float myFloatNum = 5.99;     // Floating point number
double myDoubleNum = 9.98;   // Floating point number
char myLetter = 'D';         // Character
bool myBoolean = true;       // Boolean
string myText = "Hello";     // String

Example 3: primitive and non primitive data types in c++

Primitive data types are those data types which are used by programmers when creating variables in their program. 
For example :-
    * boolean
    * char
    * byte
    * short
    * int
    * long
    * float
    * double
Non-Primitive data types:
    * String
    * array
    * enum
    * class
    * etc

Tags:

Cpp Example