Popular Tutorials
Start Learning C++Certification Courses
Created with over a decade of experience and thousands of feedback.
Python online compiler
JavaScript online compiler
SQL online compiler
Java online compiler
HTML online compiler
C online compiler
C++ online compiler
C# online compiler
PHP online compiler
Swift online compiler
Kotlin online compiler
TypeScript online compiler
Go online compiler
Rust online compiler
Scala online compiler
Dart online compiler
R online compiler
Ruby online compiler
C++ Program to Find Size of int, float, double and char in Your System
This program declares 4 variables of type int, float, double and char. Then, the size of each variable is evaluated using sizeof operator.
We can use the sizeof operator to find the size of a variable.
sizeof(dataType);
Example: Find Size of a Variable
#include <iostream>
using namespace std;
int main()
{
cout << "Size of char: " << sizeof(char) << " byte" << 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;
}
Output
Size of char: 1 byte Size of int: 4 bytes Size of float: 4 bytes Size of double: 8 bytes
Note: You may get different result if you are using a old computer.
Also Read:
Did you find this article helpful?