C ++ classroom practice two

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) << 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;
}

Share a picture< /p>

#include

#include
<string>
#include

using namespace std;

int main(){
cout
<< "int Number of sections:" << sizeof(int)<< " min:" << (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:" << (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_limitsshort int>::max)()<< endl;
cout
<< "The number of bytes occupied by unsigned long int :" << sizeof(unsigned long int)<< " min:" << (numeric_limitslong int>::min)() << " max:" << (numeric_limitslong int>::max)()<< endl;
cout
<< "char Number of sections:" << sizeof(char) << " min:" << (numeric_limits<char>::min)() << " max:" << (numeric_limits<char>::max)()<< endl;
cout
<< "Bytes occupied by signed char Number:" << sizeof(signed char)<< " min:" << (numeric_limitschar>::min)() < <" max:" << (numeric_limitschar
>::max)()<< endl;
cout
<< "bytes occupied by unsigned char Number:" << sizeof(unsigned char)<< " min:" << (numeric_limitschar>::min)() < <" max:" << (numeric_limitschar>::max)()<< endl;
cout
<< "bool Number of sections:" << sizeof(bool)<< " min:" << (numeric_limits<bool>::min)() << " max:" << (numeric_limits<bool>::max)()<< endl;
cout
<< "string Number of sections:" << sizeof(string)<< " min:" << (numeric_limits<string>::min)() << " max:" << (numeric_limits<string>::max)()<< endl;
cout
<< "double Number of sections:" << sizeof(double)<< " min:" << (numeric_limits<double>::min)() << " max:"< /span> << (numeric_limits<double>::max)()<< endl;
cout
<< "The word occupied by float Number of sections:" << sizeof(float)<< " min:" << (numeric_limits<float>::min)() << " max:"< /span> << (numeric_limits<float>::max)()<< endl;
return 0;
}

Share a picture< /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) << 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:" << (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:" << (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_limitsshort int>::max)()<< endl;
cout
<< "The number of bytes occupied by unsigned long int :" << sizeof(unsigned long int)<< " min:" << (numeric_limitslong int>::min)() << " max:" << (numeric_limitslong int>::max)()<< endl;
cout
<< "char Number of sections:" << sizeof(char) << " min:" << (numeric_limits<char>::min)() << " max:" << (numeric_limits<char>::max)()<< endl;
cout
<< "Bytes occupied by signed char Number:" << sizeof(signed char)<< " min:" << (numeric_limitschar>::min)() < <" max:" << (numeric_limitschar
>::max)()<< endl;
cout
<< "bytes occupied by unsigned char Number:" << sizeof(unsigned char)<< " min:" << (numeric_limitschar>::min)() < <" max:" << (numeric_limitschar>::max)()<< endl;
cout
<< "bool Number of sections:" << sizeof(bool)<< " min:" << (numeric_limits<bool>::min)() << " max:" << (numeric_limits<bool>::max)()<< endl;
cout
<< "string Number of sections:" << sizeof(string)<< " min:" << (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;
}

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2178 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.