Some of the data types which we have discussed earlier:int,float,char,string,etc. are used explicitly in C++ program but there are some other types which we may or may not use explicitly in our C++ program.Some of these types discuss here will come in handy while writing a C++ program,while the others will help in understanding some of the programming and non-programming(but computer) stuff.
Void has no type.In other words void means no type at all.In C++ program if void is used as a type it means it does not belong to any of the basic built-in type or user-defined or any other types discussed here.So if you want to use a type but not supporting any value then use void.The keyword for such type is void.It is used while returning value from function(discuss in Chapter 2 ).
Bool type supports only two values:true and false.True when converted to int type it is same as the integer value 1 and false is same as the integer value 0.Note that whenever you assigned an integer value to the bool variable any integer other than 0 is true.The keyword of bool type is bool itself.
cout<< b1 << endl
<< b2 << endl
<< b3 << endl
<< b4 << endl ;
The output is
Don’t get confused with the output here ,1 means true and 0 means false.So you see any non-zero value is a true value.
Decimal type value are represented from the value 0 to 9,for instance 8549349 .Note decimal value is same as int type value so integer and decimal may be used interchangeably in C++.There is no specific keyword for decimal type so if you want to use a decimal type you can use the int type .
Octal type value are represented from the value 0 to 8,for instance 743812.We cannot include the integer 9 to represent the value of such type.There is no specific keyword for such type in C++ so they cannot be used explicitly in our program.You can Google for more information on how to use this type for numbering system
Hexadecimal type uses the integer value from 0 to 9 and a,b,c,d,e,f(can be upper case either:meaning capital letter) as 11,12,13,14,15, for numbering system.For instance the integer value 84954 is represented as 0x14BDA in hexadecimal system.This type is use to represent the memory address in our Computer.There is no specific keyword for such type in C++ so they cannot be used explicitly in C++ program.
C++ provides us with some functions through which we can output decimal ,hexadecimal and octal value in our program.The program is given below.
using namespace std;
int main( )
cout << dec << 547458 << endl //Prints out decimal value
<< hex << 83498 << endl //Prints out hexadecimal value
<< oct << 832679 ; //Prints out octal value
return 0 ;
You can check the output by running the program.