BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Data Types in C++

Last Updated: September 11, 2017 by Chaitanya Singh | Filed Under: Learn C++

Data types define the type of data a variable can hold, for example an integer variable can hold integer data, a character type variable can hold character data etc.

Data types in C++ are categorised in three groups: Built-in, user-defined and Derived.
data types in c++

Built in data types

char: For characters. Size 1 byte.

char ch = 'A';

int: For integers. Size 2 bytes.

int num = 100;

float: For single precision floating point. Size 4 bytes.

float num = 123.78987;

double: For double precision floating point. Size 8 bytes.

double num = 10098.98899;

bool: For booleans, true or false.

bool b = true;

wchar_t: Wide Character. This should be avoided because its size is implementation defined and not reliable.

User-defined data types

We have three types of user-defined data types in C++
1. struct
2. union
3. enum

I have covered them in detail in separate tutorials. For now just remember that these comes under user-defined data types.

Derived data types in C++

We have three types of derived-defined data types in C++
1. Array
2. Function
3. Pointer

They are wide topics of C++ and I have covered them in separate tutorials. Just follow the tutorials in given sequence and you would be fine.

❮ PreviousNext ❯

Top Related Articles:

  1. Hello World – First C++ Program
  2. Pointers in C++
  3. Function Overriding in C++
  4. Variables in C++
  5. Operators in C++

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap