TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

C++

C++ Intrinsic data types

Overview

C++ intrinsic data types are built into the language. These are also called primitive data types. There are several intrinsic datatypes that developers can declare and use the variables in the C++ programs.

C++ Intrinsic Datatypes

Some of the examples are as follows:

  • bool
  • char
  • int
  • float
  • double
  • void

Based on the data type the operating system allocates memory for the variables.

C++ Built-in Datatypes

void no type
bool boolean
char character
int integer
float single-precision floating-point
double double-precision floating-point
wchat_t wide character type

 

The below program displays the sizes of various primitive datatypes onto the console in bytes.

C++ Program

/************************************
* C++ Intrinsic DataTypes
* Filename: datatypes.cpp
* C++ Tutorials - www.TestingDocs.com
**************************************/
#include 
using namespace std;
int main()
{
 cout << "C++ Intrinsic DataTypes" << endl;
 cout << "Size void Datatype : " << sizeof(void) << " bytes "<<endl;
 cout << "Size bool Datatype : " << sizeof(bool) << " bytes "<<endl;
 cout << "Size char Datatype : " << sizeof(char) << " bytes "<<endl;
 cout << "Size int Datatype : " << sizeof(int) << " bytes "<<endl;
 cout << "Size float Datatype : " << sizeof(float) << " bytes "<<endl;
 cout << "Size double Datatype: " << sizeof(double) << " bytes "<<endl;

 return 0;
} // end main

Output

C++ Intrinsic DataTypes
Size void Datatype : 1 bytes
Size bool Datatype : 1 bytes
Size char Datatype : 1 bytes
Size int Datatype : 4 bytes
Size float Datatype : 4 bytes
Size double Datatype: 8 bytes

 

C++ Intrinsic Datatypes

 

The sizeof() function returns the size of the data type passed to the function. For example, sizeof(char) returns 1. The units of the function are Bytes.

—

C++ Tutorials

C++ Tutorials on this website:

https://www.testingdocs.com/c-coding-tutorials/

For more information on the current ISO C++ standard

https://isocpp.org/std/the-standard

Related Posts

g not found OpenSuse

C++ /

Install GCC C++ Compiler on OpenSuse

sum of digits c program

C++ /

Sum of Digits of a Number C++ Program

C++ Hello World Program

C++ /

C++ Hello World Program

C++ /

Object-Oriented Programming Language Examples

C++ /

Object-Oriented Programming Features

‹ C++ Comments› C++ Input Statement

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version