Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

climits in cpp

// #include <climits>

{
    int Year = 2022;
    char tech = 'y';
    bool BiggerThan32 = 't';
    float AvaRageGrade = 4.5;
    double balance = 13425346576876;
    cout << "Size of int is "<<sizeof(int) <<"bytes
";
    cout << "int max value is "<< INT_MAX << endl;
    cout << "int min value is " << INT_MIN << endl;
    cout << "size of unsigned int "<<sizeof(unsigned int) <<"bytes
";
    cout << "Uint max value is " << UINT_MAX << endl;
    cout << "Size of bool is "<< sizeof(bool) <<"bytes
";
    cout << "Size of char is " << sizeof(char) <<"bytes
";
    cout << "size of float is " << sizeof(float)<<"bytes
";
    cout <<"size of double is"<<sizeof(double)<< "bytes
";
    
    return 0;
}

//RESULT 
// Size of int is 4bytes
// int max value is 2147483647
// int min value is-2147483648 (the 1 bit difference from the max value is coming because of the 0 as it's counted as well.)
// size of unsigned int4bytes
// Uint max value is 4294967295
// Size of bool is 1bytes
// Size of char is 1bytes
// size of float is 4bytes
// size of double is8bytes

// OTHER USES

// CHAR_MIN:- Minimum value for an object of type char. Value of CHAR_MIN is either -127 (-27+1) or less or 0.
// CHAR_MAX:- Minimum value for an object of type char. Value of CHAR_MIN is either -127 (-27+1) or less or 0.
// SHRT_MIN:- Minimum value for an object of type short int. Value of SHRT_MIN is -32767 (-215+1) or less.
// SHRT_MAX:- Maximum value for an object of type short int. Value of SHRT_MAX is 32767 (215-1) or greater.
// USHRT_MAX:- Maximum value for an object of type unsigned short int. Value of USHRT_MAX is 65535 (216-1) or greater.
// INT_MIN:- Minimum value for an object of type int. Value of INT_MIN is -32767 (-215+1) or less.
// INT_MAX:- Maximum value for an object of type int. Value of INT_MAX is 32767 (215-1) or greater.
// UINT_MAX:- Maximum value for an object of type unsigned int. Value of UINT_MAX is 65535 (216-1) or greater.
// LONG_MIN:- Minimum value for an object of type long int. Value of LONG_MIN is -2147483647 (-231+1) or less.
// LONG_MAX:- Maximum value for an object of type long int. Value of LONG_MAX is 2147483647 (231-1) or greater.
// ULONG_MAX:- Maximum value for an object of type unsigned long int. Value of ULONG_MAX is 4294967295 (232-1) or greater.
// LLONG_MIN:- Minimum value for an object of type long long int. Value of LLONG_MIN is -9223372036854775807 (-263+1) or less.
// LLONG_MAX:- Maximum value for an object of type long long int. Value of LLONG_MAX is 9223372036854775807 (263-1) or greater.
// ULLONG_MAX:- Maximum value for an object of type unsigned long long int. Value of ULLONG_MAX is 18446744073709551615 (264-1) or greater.
 
PREVIOUS NEXT
Tagged: #climits #cpp
ADD COMMENT
Topic
Name
2+1 =