Popular Google Pages:
◕ Your Story ₹ 500/- Details..
◕ Bengali Story writing competition. Details..
This article is regarding sizeof Operator in C++.
Last updated on: 15th November 2016.
Choose your Language: English Bengali
◕ Let a simple program:
using namespace std;
int man = 2;
cout << "int is a Type. The size of this Type is " << sizeof (int) << " Bytes." << endl;
cout << "man is a Variable. The size of this Variable is " << sizeof (int) << " Bytes." << endl;
◕ This above program will produce the following answer:
int is a Type. The size of this Type is 4 Bytes.
int is a Variable. The size of this Variable is 4 Bytes.
◕ In the above example:
The sizeof is an Operator in the C++. We can say an Operator is a Built-in-Language Element that operates on one or more items. Such as addition ( + ), subtraction ( - ), multiplication ( x ) and divide ( / ).
When we use the sizeof operates then we have to include the climits header file.
The sizeof operator returns the size of a Type or size of a Variable in Bytes.
◕ Please note that:
- When we use sizeof operator to find the size of a Type such as int, then we enclose the Type in parentheses.
- And when we use sizeof operator to find the size of a Variable such as man, then parentheses is optional.
- The size of a Type may vary in different system due climits header file. Because different manufacturers make it differently.
Top of the page