C++-- Size of data with Eclipse IDE

Objectives:

  • Sizeof data, declaration and initialization of variables.
  • It could be isolated case, one point the project did not refresh and Eclipse IDE failed to refresh, clean and rebuild the project
  • Eclipse workspace were restarted
  • dynamic initialization of a variable

Step: 1 Create new Project using eclipse IDE

Create a source file with extension cpp

 

Step: 2 Code and runtime views

#include <iostream>
using namespace std;
int main()
{
int n1 = 12; char ch1 = 'a';
double d1 = 12.34; // declaring and initializing variable
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";
double dynamic = n1 + d1 + f1;
cout<< "dynamic initialization of a variable " << dynamic << endl;
char myline[100];
cin.getline(myline, 100);
return 0;
}
 

Step 3 Runtime Views