Here is a sample C++ code, I have written to find data type size. Basically I am just using sizeof() function to find size of any data type.
#include <iostream>
using namespace std;
int main() {
cout << "Sizes of different types:" << endl;
cout << "char - " << sizeof(char) << " bytes" << endl;
cout << "short - " << sizeof(short) << " bytes" << endl;
cout << "int - " << sizeof(int) << " bytes" << endl;
cout << "long - " << sizeof(long) << " bytes" << endl;
cout << "float - " << sizeof(float) << " bytes" << endl;
cout << "double - " << sizeof(double) << " bytes" << endl;
cout << endl << "Thank you :)" << endl;
return 0;
}