C++ sizeof Operator

C++ sizeof Operator

Version
Download 7
Total Views 0
Stock
File Size 1.30 KB
File Type zip
Create Date May 9, 2016
Last Updated May 9, 2016
Download

C++ sizeof Operator
sizeof Operator will return a number of bytes in a variable or data type. This c++ program will display the size of 4 datatypes (char, int, float and double) in bytes.

Open the main.cpp in codeblocks or whatever ide you are using that supports c++.

Source code:

#include < iostream >

using namespace std;

int main()
{
    cout << "Size of char : " <<  sizeof(char) << " bytes" <<  endl;
    cout << "Size of int : " <<  sizeof(int) <<  " bytes"  << endl;
    cout << "Size of float : " <<  sizeof(float) <<  " bytes" << endl;
    cout << "Size of double : " << sizeof(double) <<  " bytes" << endl;
    return 0;
}

Comments

comments

Leave a Reply

Your email address will not be published. Required fields are marked *

*