Monday, 26 September 2011

Program to find the size of data types.


#include <iostream.h>
#include <conio.h>
#include <float.h>


main()
{
   cout << "Number of bytes used.\n\n";
   cout << "\tchar           : " << sizeof(char)           << endl;
   cout << "\tshort          : " << sizeof(short)          << endl;
   cout << "\tint            : " << sizeof(int)            << endl;
   cout << "\tlong           : " << sizeof(long)           << endl;
   cout << "\tunsigned char  : " << sizeof(unsigned int)   << endl;
   cout << "\tunsigned short : " << sizeof(unsigned short) << endl;
   cout << "\tunsigned int   : " << sizeof(unsigned int)   << endl;
   cout << "\tsigned char    : " << sizeof(signed char)    << endl;
   cout << "\tfloat          : " << sizeof(float)          << endl;
   cout << "\tdouble         : " << sizeof(double)         << endl;
   cout << "\tlong double    : " << sizeof(long double)    << endl;
   getch();
}







No comments:

Post a Comment