C++ Online Compiler
Example: C++ program to find the size of all data types using the sizeof operator
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// C++ program to find the size of all data types using the sizeof operator #include <bits/stdc++.h> using namespace std; // Driver Program int main() { // Calculate the size of short int data type cout <<"The size of short int: " << sizeof(short int) << " bytes\n"; // Calculate the size of unsigned short int data type cout <<"The size of unsigned short int: " << sizeof(unsigned short int) << " bytes\n"; // Calculate the size of unsigned int data type cout <<"The size of unsigned int: " << sizeof(unsigned int) << " bytes\n"; // Calculate the size of int data type cout <<"The size of int: " << sizeof(int) << " bytes\n"; // Calculate the size of long int data type cout <<"The size of long int: " << sizeof(long int) << " bytes\n"; // Calculate the size of unsigned long int data type cout <<"The size of unsigned long int: " << sizeof(unsigned long int) << " bytes\n"; // Calculate the size of long long int data type cout <<"The size of long long int: " << sizeof(long long int) << " bytes\n"; // Calculate the size of unsigned long long int data type cout <<"The size of unsigned long long int: " << sizeof(unsigned long long int) << " bytes\n"; // Calculate the size of signed char data type cout <<"The size of signed char: " << sizeof(signed char) << " byte\n"; // Calculate the size of unsigned char data type cout <<"The size of unsigned char: " << sizeof(unsigned char) << " byte\n"; // Calculate the size of char data type cout <<"The size of char: " << sizeof(char) << " byte\n"; // Calculate the size of float data type cout <<"The size of float: " << sizeof(float) << " bytes\n"; // Calculate the size of double data type cout <<"The size of double: " << sizeof(double) << " bytes\n"; // Calculate the size of long double data type cout <<"The size of long double: " << sizeof(long double) << " bytes\n"; return 0; }
Output
Clear
ADVERTISEMENTS