Write a simple program that uses the sizeof function to di
Solution
*Note if you are using Linux, there are minor differences in code for windows and linux editors. I have mentionined both of them here, pick whichever you prefer.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1.This is Windows version of the code (i.e.Turbo C++) :
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<\"Size Of short int -->\"<<size0f(short int) <<endl;
cout<<\"Size Of int -->\"<<sizeof(int)<<endl;
cout<<\"Size Of long int -->\"<<sizeof(long int)<<endl;
cout<<\"Size Of char -->\"<<sizeof(char)<<endl;
cout<<\"Size Of float -->\"<<sizeof(float)<<endl;
cout<<\"Size Of double -->\"<<sizeof(double)<<endl;
getch();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2. This is Linux Version of the code :
#include<iostream>
using namespace std;
int main()
{
cout<<\"Size Of short int -->\"<<size0f(short int) <<endl;
cout<<\"Size Of int -->\"<<sizeof(int)<<endl;
cout<<\"Size Of long int -->\"<<sizeof(long int)<<endl;
cout<<\"Size Of char -->\"<<sizeof(char)<<endl;
cout<<\"Size Of float -->\"<<sizeof(float)<<endl;
cout<<\"Size Of double -->\"<<sizeof(double)<<endl;
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

