C++ Exercises
C++ Program to Print Data type sizes.
Let see the program example to print datatype sizes. It contains different data sizes in the 32-bit operating system and a 64-bit operating system.
The below example display datatype sizes in the 64-bit operating system.The function sizeof() used to display data type sizes.
#include <iostream> using namespace std; int main() { int x; float y; double z; char ch; cout<<"\n Display int data type size "<<sizeof(x)<<" Bytes"<<endl; cout<<"\n Display float data type size "<<sizeof(y)<<" Bytes"<<endl; cout<<"\n Display double data type size "<<sizeof(z)<<" Bytes"<<endl; cout<<"\n Display char data type size "<<sizeof(ch)<<" Bytes"<
Output:
Display int data type size 4 Bytes Display float data type size 4 Bytes Display double data type size 8 Bytes Display char data type size 1 Bytes