Size Of Variable Types

Another simple program…to determine the exact size of data types on your computer (output may vary):

#include <iostream.h>
 
int main(){
    cout << "The size of an int is:\t\t" << sizeof(int) << " bytes.\n";
    cout << "The size of a short is:\t\t" << sizeof(short) << " bytes.\n";
    cout << "The size of a long is:\t\t" << sizeof(long) << " bytes.\n";
    cout << "The size of a char is:\t\t" << sizeof(char) << " bytes.\n";
    cout << "The size of a float is:\t\t" << sizeof(float) << " bytes.\n";
    cout << "The size of a double is:\t" << sizeof(double) << " bytes.\n";
 
    return 0;
}
cpp
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License