Visual C++- variable size -- sizeof(variable-type);

Step: 1 Create new Project

Step: 2 edit the code

#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int n1 = 12; char ch1 = 'a';
double d1 = 12.34;
float f1 = 24.56;
cout<<"Size of integer n1 is \t" << sizeof(n1) << " Bytes\n";
cout<<"Size of char ch1 is \t" << sizeof(ch1) << " Bytes\n";
cout<<"Size of double d1 is \t" << sizeof(d1) << " Bytes\n";
cout<<"Size of float f1 is \t" << sizeof(f1) << " Bytes\n";
char myline[100];
cin.getline(myline, 100);
return 0;
}

 

Step: 3 Runtime views