Stroustrup 4.11 exercise 5
MAX and MIN values of CHAR could not be displayed. Why ?
BTW, any advice on improvement ?
(please remember i have covered chapter 4 only)
------------- PROGRAMME --------------
/* Stroustrup 3e, section 4.11, exercise 5
STATEMENT:
what, on your system, are the largest and smallest values of the
following types:
char, short, int, long, float, double, long double and unsigned.
*/
#include<iostream>
#include<limits>
int main()
{
std::cout << "Largest float == " <<
std::numeric_limits<float>::max() << '\n';
std::cout << "Smallest float == " <<
std::numeric_limits<float>::min() << '\n';
std::cout << "Largest double == " <<
std::numeric_limits<double>::max() << '\n';
std::cout << "Smallest double == " <<
std::numeric_limits<double>::min() << '\n';
std::cout << "Largest long double == " <<
std::numeric_limits<long double>::max() << '\n';
std::cout << "smallest long double == " <<
std::numeric_limits<long double>::min() << '\n';
std::cout << '\n';
std::cout << "Largest char == " <<
std::numeric_limits<char>::max() << '\n';
std::cout << "Smallest char == " <<
std::numeric_limits<char>::min() << '\n';
std::cout << "Largest int == " <<
std::numeric_limits<int>::max() << '\n';
std::cout << "Smallest int == " <<
std::numeric_limits<int>::min() << '\n';
std::cout << "Largest short == " <<
std::numeric_limits<short>::max() << '\n';
std::cout << "Smallest short == " <<
std::numeric_limits<short>::min() << '\n';
std::cout << '\n';
std::cout << "Largest Unsigned (int) == " <<
std::numeric_limits<unsigned>::max() << '\n';
std::cout << "Smallest Unsigned (int) == " <<
std::numeric_limits<unsigned>::min() << '\n';
std::cout << "Largest Long (int) == " <<
std::numeric_limits<long>::max() << '\n';
std::cout << "Smallest Long (int) == " <<
std::numeric_limits<long>::min() << '\n';
return 0;
}
------------- OUTPUT -------------
[arch@voodo tc++pl]$ g++ -pedantic -ansi -Wall -Wextra 4.11_5.cpp
[arch@voodo tc++pl]$ ./a.out
Largest float == 3.40282e+38
Smallest float == 1.17549e-38
Largest double == 1.79769e+308
Smallest double == 2.22507e-308
Largest long double == 1.18973e+4932
smallest long double == 3.3621e-4932
Largest char ==
Smallest char == ?
Largest int == 2147483647
Smallest int == -2147483648
Largest short == 32767
Smallest short == -32768
Largest Unsigned (int) == 4294967295
Smallest Unsigned (int) == 0
Largest Long (int) == 2147483647
Smallest Long (int) == -2147483648
[arch@voodo tc++pl]$