C++ Program to find the Size of data types


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#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

C++ language tech study

     





Related Topics




Popular Posts