Data Types with sizes

The Data types size may be differ according to your system and compiler that you used for coding . In this program we first declare all these data types with simple variable name and after this pass this variable to C++ size of function.

Source Code

#include <iostream>
using namespace std;

int main()
{
   char a;
   int b;
   short int c;
   long int d;
   float e;
   double f;
   wchar_t g;
   cout<<" \t \t \t Size of Different Data Types ";
   cout<<endl;
   cout << " The Size of char      : " << sizeof(a) << endl;
   cout << " The Size of int       : " << sizeof(b) << endl;
   cout << " The Size of short int : " << sizeof(c) << endl;
   cout << " The Size of long int  : " << sizeof(d) << endl;
   cout << " The Size of float     : " << sizeof(e) << endl;
   cout << " The Size of double    : " << sizeof(f) << endl;
   cout << " The Size of wchar_t   : " << sizeof(g) << endl;
   return 0;
}

Output of the Program

Data Types with sizes

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment