MOCKSTACKS
EN
Questions And Answers

More Tutorials








C++ Data Types

In previous section you learned how to declare a variable, and we mentioned that you will need the data type in order to do that.

Below is a list of basic data types supported by C++:

  • int: These type of of variables holds integer value.
  • char: holds character value like ‘c’, ‘F’, ‘B’, ‘p’, ‘q’ etc.
  • bool: holds boolean value true or false.
  • double: double-precision floating point value.
  • float: Single-precision floating point value.

Several of the basic types can be modified using one or more of these type modifiers

  • signed
  • unsigned
  • short
  • long

Below table will show more information about C++ data types:

TypeTypical Bit WidthTypical Range
char1byte-127 to 127 or 0 to 255
unsigned char1byte0 to 255
signed char1byte-127 to 127
int4bytes-2147483648 to 2147483647
unsigned int4bytes0 to 4294967295
signed int4bytes-2147483648 to 2147483647
short int2bytes-32768 to 32767
unsigned short int2bytes0 to 65,535
signed short int2bytes-32768 to 32767
long int8bytes-2,147,483,648 o 2,147,483,647
signed long int8bytessame as long int
unsigned long int8bytes0 to 4,294,967,295
long long int8bytes-(2^63) to (2^63)-1
unsigned long long int8bytes0 to 18,446,744,073,709,551,615
float4bytes/td>
double8bytes
long double12bytes
wchar_t2 r 4 bytes1 wide character



Conclusion

In this page (written and validated by ) you learned about C++ Data Types . What's Next? If you are interested in completing Cpp tutorial, your next topic will be learning about: Cpp Output function.



Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com.


Share On:


Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using Mockstacks.com, you agree to have read and accepted our terms of use, cookies and privacy policy.