Senin, 08 Desember 2025

listing3.5.cpp sizeof(variable)

// listing3.5.cpp
#include <iostream>
using namespace std;

int main()
{
    cout << "Computing the size of inbuilt variable types" << endl << endl;

    cout << "size of bool: " << sizeof(bool) << endl;
    cout << "size of char: " << sizeof(char) << endl;
    cout << "size of unsigned short int: " << sizeof(unsigned short) << endl;
    cout << "size of short int: " << sizeof(short) << endl;
    cout << "size of unsigned long int: " << sizeof(unsigned long) << endl;
    cout << "size of long: " << sizeof(long) << endl;
    cout << "size of int: " << sizeof(int) << endl;
    cout << "size of uns. long long: " << sizeof(unsigned long long) << endl;
    cout << "size of unsigned int: " << sizeof(unsigned int) << endl;
    cout << "size of float: " << sizeof(float) << endl;
    cout << "size of double: " << sizeof(double) << endl << endl;

    cout << "The output changes with compiler, hardware, and OS" << endl;
    return 0;
}

output:
 
Computing the size of inbuilt variable types

size of bool: 1
size of char: 1
size of unsigned short int: 2
size of short int: 2
size of unsigned long int: 4
size of long: 4
size of int: 4
size of uns. long long: 8
size of unsigned int: 4
size of float: 4
size of double: 8

The output changes with compiler, hardware, and OS

Process returned 0 (0x0)   execution time : 0.093 s
Press any key to continue.

Tidak ada komentar:

Posting Komentar