1. The type of data and the number of bytes it occupies
#include
#include<string>
using namespace std;
int main(){
cout << "********** *****************************" << endl;
cout << "int:"<< sizeof(int ) << endl;
cout << "short int:"<< sizeof(short int) << endl;
cout << "long int:"<< sizeof(int) << endl;
cout << "unsigned int:"<< sizeof(unsigned int span>) << endl;
cout << "unsigned short int:"<< sizeof(unsigned short< /span> int) << endl;
cout << "unsigned long int:"<< sizeof(unsigned long< /span> int) << endl;
cout << "char:"<< sizeof(char ) << endl;
cout << "unsigned char:"<< sizeof(unsigned char) << endl;
cout << "bool:"<< sizeof(bool ) << endl;
cout << "double:"<< sizeof(double ) << endl;
cout << "float:"<< sizeof(float ) << endl;
cout << "********** *****************************" << endl;
cout << "A:" << sizeof(' A') << endl ;
cout << "1:" << sizeof(1 ) << endl;
cout << "1.0:" << sizeof(1.0 ) << endl;
cout << "True:" << sizeof(true ) << endl;
cout << "hello World:" << sizeof("Hello World") << endl;
cout << "Program:" << sizeof(" Program") << endl ;
cout << "********** *****************************" << endl;
return 0;
}
< /p>
#include
#include<string>
#include
using namespace std;
int main(){
cout << "int Number of sections:" << sizeof(int)<< " min: span>" << (numeric_limits<int>::min)() << " max: " << (numeric_limits<int>::max)()<< endl;
cout << "Bytes occupied by short int Number:" << sizeof(short int)<< " min:" << (numeric_limits<short int>::min)() << " max:" << (numeric_limits<short int>::max)()<< endl;
cout << "Bytes occupied by long int Number:" << sizeof(long int) << " min:" << (numeric_limits<long int>::min)() << " max:" << (numeric_limits<long int>::max)()<< endl;
cout << "Bytes occupied by unsigned int Number:" << sizeof(unsigned int)<< " min: span>" << (numeric_limitsint >::min)() < <" max:" << (numeric_limitsint >::max)()<< endl;
cout << "The number of bytes occupied by unsigned short int :" << sizeof(unsigned short int)<< " min:" << (numeric_limitsshort int>::min)() << " max:" << (numeric_limits short int>::max)()<< endl;
cout << "The number of bytes occupied by unsigned long int :" << sizeof(unsigned long int)<< " min:" << (numeric_limitslong int>::min)() << " max:" << (numeric_limits long int>::max)()<< endl;
cout << "char Number of sections:" << sizeof(char) << " min: span>" << (numeric_limits<char>::min)() << " max:" << (numeric_limits<char>::max)()<< endl;
cout << "Bytes occupied by signed char Number:" << sizeof(signed char)<< " min: span>" << (numeric_limitschar >::min)() < <" max:" << (numeric_limitschar >::max)()<< endl;
cout << "bytes occupied by unsigned char Number:" << sizeof(unsigned char)<< " min: span>" << (numeric_limitschar >::min)() < <" max:" << (numeric_limitschar>::max)()<< endl;
cout << "bool Number of sections:" << sizeof(bool)<< " min: span>" << (numeric_limits<bool>::min)() << " max:" << (numeric_limits<bool>::max)()<< endl;
cout << "string Number of sections:" << sizeof(string)<< " min: span>" << (numeric_limits<string>::min)() << " max:" << (numeric_limits<string>::max)()<< endl;
cout << "double Number of sections:" << sizeof(double)<< " min: span>" << (numeric_limits<double>::min)() << " max:"< /span> << (numeric_limits<double>::max)()<< endl;
cout << "The word occupied by float Number of sections:" << sizeof(float)<< " min: span>" << (numeric_limits<float>::min)() << " max:"< /span> << (numeric_limits<float>::max)()<< endl;
return 0;
}
< /p>
#include
#include<string>
using namespace std;
int main(){
cout << "********** *****************************" << endl;
cout << "int:"<< sizeof(int ) << endl;
cout << "short int:"<< sizeof(short int) << endl;
cout << "long int:"<< sizeof(int) << endl;
cout << "unsigned int:"<< sizeof(unsigned int span>) << endl;
cout << "unsigned short int:"<< sizeof(unsigned short< /span> int) << endl;
cout << "unsigned long int:"<< sizeof(unsigned long< /span> int) << endl;
cout << "char:"<< sizeof(char ) << endl;
cout << "unsigned char:"<< sizeof(unsigned char) << endl;
cout << "bool:"<< sizeof(bool ) << endl;
cout << "double:"<< sizeof(double ) << endl;
cout << "float:"<< sizeof(float ) << endl;
cout << "********** *****************************" << endl;
cout << "A:" << sizeof(' A') << endl ;
cout << "1:" << sizeof(1 ) << endl;
cout << "1.0:" << sizeof(1.0 ) << endl;
cout << "True:" << sizeof(true ) << endl;
cout << "hello World:" << sizeof("Hello World") << endl;
cout << "Program:" << sizeof(" Program") << endl ;
cout << "********** *****************************" << endl;
return 0;
}
#include
#include<string>
#include
using namespace std;
int main(){
cout << "int Number of sections:" << sizeof(int)<< " min: span>" << (numeric_limits<int>::min)() << " max: " << (numeric_limits<int>::max)()<< endl;
cout << "Bytes occupied by short int Number:" << sizeof(short int)<< " min:" << (numeric_limits<short int>::min)() << " max:" << (numeric_limits<short int>::max)()<< endl;
cout << "Bytes occupied by long int Number:" << sizeof(long int) << " min:" << (numeric_limits<long int>::min)() << " max:" << (numeric_limits<long int>::max)()<< endl;
cout << "Bytes occupied by unsigned int Number:" << sizeof(unsigned int)<< " min: span>" << (numeric_limitsint >::min)() < <" max:" << (numeric_limitsint >::max)()<< endl;
cout << "The number of bytes occupied by unsigned short int :" << sizeof(unsigned short int)<< " min:" << (numeric_limitsshort int>::min)() << " max:" << (numeric_limits short int>::max)()<< endl;
cout << "The number of bytes occupied by unsigned long int :" << sizeof(unsigned long int)<< " min:" << (numeric_limitslong int>::min)() << " max:" << (numeric_limits long int>::max)()<< endl;
cout << "char Number of sections:" << sizeof(char) << " min: span>" << (numeric_limits<char>::min)() << " max:" << (numeric_limits<char>::max)()<< endl;
cout << "Bytes occupied by signed char Number:" << sizeof(signed char)<< " min: span>" << (numeric_limitschar >::min)() < <" max:" << (numeric_limitschar >::max)()<< endl;
cout << "bytes occupied by unsigned char Number:" << sizeof(unsigned char)<< " min: span>" << (numeric_limitschar >::min)() < <" max:" << (numeric_limitschar>::max)()<< endl;
cout << "bool Number of sections:" << sizeof(bool)<< " min: span>" << (numeric_limits<bool>::min)() << " max:" << (numeric_limits<bool>::max)()<< endl;
cout << "string Number of sections:" << sizeof(string)<< " min: span>" << (numeric_limits<string>::min)() << " max:" << (numeric_limits<string>::max)()<< endl;
cout << "double 所占字节数:" << sizeof(double)<< " min:" << (numeric_limits<double>::min)() << " max:" << (numeric_limits<double>::max)()<< endl;
cout << "float 所占字节数:" << sizeof(float)<< " min:" << (numeric_limits<float>::min)() << " max:" << (numeric_limits<float>::max)()<< endl;
return 0;
}