Q:

C++ Program to find the Size of data types

0

C++ Program to find the Size of data types

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<iostream>
using namespace std;

int main()
{
    char charType;
    short shortType;
    int intType;
    long longType;
    float floatType;
    double doubleType;

    // Sizeof operator is used to evaluate the size of a declared data type
    
    cout << "Size of char: " << sizeof(charType) <<" byte" << endl;
    cout<<"Size of Short: " << sizeof(shortType) <<" bytes" << endl;

    cout<<"Size of int: " << sizeof(intType) <<" bytes" << endl;
    cout<<"Size of long: " << sizeof(longType) <<" bytes" << endl;

    cout<<"Size of float: " << sizeof(floatType) <<" bytes" << endl;
    cout<<"Size of double: " << sizeof(doubleType) <<" bytes" << endl;

    return 0;;
}

Result:

Size of char: 1 byte

Size of Short: 2 bytes

Size of int: 4 bytes

Size of long: 8 bytes

Size of float: 4 bytes

Size of double: 8 bytes

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Program to Calculate Area of Circle... >>
<< C++ Program to convert farenheit to celcius...