Write a C++ Program to Find Size of Int Float Double and Char data types. Here’s simple Program to Find Size of Int Float Double and Char data types in C++ Programming Language.
To find the size of variable, sizeof operator is used i.e sizeof(dataType).
Here is source code of the C++ Program to Find Size of Int Float Double and Char data types. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.
SOURCE CODE : :
/* C++ Program to Find Size of Int Float Double and Char data types */
#include <iostream>
using namespace std;
int main()
{
cout << "Size of char: " << sizeof(char) << " byte" << endl;
cout << "\nSize of int: " << sizeof(int) << " bytes" << endl;
cout << "\nSize of float: " << sizeof(float) << " bytes" << endl;
cout << "\nSize of double: " << sizeof(double) << " bytes" << endl;
return 0;
}
Output : :
/* C++ Program to Find Size of Int Float Double and Char data types */
Size of char: 1 byte
Size of int: 4 bytes
Size of float: 4 bytes
Size of double: 8 bytes
Process returned 0
Above is the source code for C++ Program to Find Size of Int Float Double and Char data types which is successfully compiled and run on Windows System.The Output of the program is shown above .
To find the size of variable, sizeof operator is used i.e sizeof(dataType).
Here is source code of the C++ Program to Find Size of Int Float Double and Char data types. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.
SOURCE CODE : :
Output : :
Above is the source code for C++ Program to Find Size of Int Float Double and Char data types which is successfully compiled and run on Windows System.The Output of the program is shown above .
need an explanation for this answer? contact us directly to get an explanation for this answer