Using the sizeof keyword in c++
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
cout << "The size of char is" << setw (9) << ": "
<< sizeof (char) << " byte" << endl;
cout << "The size of short is" << setw (8) << ": "
<< sizeof (short) << " byte" << endl;
cout << "The size of int is" << setw (10) << ": "
<< sizeof (int) << " byte" << endl;
cout << "The size of long is" << setw (9) << ": "
<< sizeof (long) << " byte" << endl;
cout << "The size of float is" << setw (8) << ": "
<< sizeof (float) << " byte" << endl;
cout << "The size of double is" << setw (7) << ": "
<< sizeof (double) << " byte" << endl;
cout << "The size of long double is" << setw (2) << ": "
<< sizeof (long double) << " byte" << endl;
return 0;
}
#include <iomanip>
using namespace std;
int main ()
{
cout << "The size of char is" << setw (9) << ": "
<< sizeof (char) << " byte" << endl;
cout << "The size of short is" << setw (8) << ": "
<< sizeof (short) << " byte" << endl;
cout << "The size of int is" << setw (10) << ": "
<< sizeof (int) << " byte" << endl;
cout << "The size of long is" << setw (9) << ": "
<< sizeof (long) << " byte" << endl;
cout << "The size of float is" << setw (8) << ": "
<< sizeof (float) << " byte" << endl;
cout << "The size of double is" << setw (7) << ": "
<< sizeof (double) << " byte" << endl;
cout << "The size of long double is" << setw (2) << ": "
<< sizeof (long double) << " byte" << endl;
return 0;
}
No comments:
Post a Comment