On Mar 5, 10:21 am, "arnuld" <geek.arn...@gmail.comwrote:
here Stroustrup asks to write the smallest and largest values of char,
int, short, long etc.
i do not understand his question. when i will do
sizeof(char), i wil only get one value in /byte/. where are the
smallest and largest values of /char/
?
He asks what the largest values are *on your system*. Different
systems can have different sizes for these types. Write a little
program that prints out the minimum and maximum value of each type.
You can try to calculate them by hand, or you can just use the
constants in <climitsor the functions that are in <limits>. For
instance:
#include <iostream>
#include <climits>
#include <limits>
using namespace std;
int main()
{
cout << "char's min and max on this system are: "
<< CHAR_MIN << " and " << CHAR_MAX;
cout << "char's min and max on this system are: "
<< numeric_limits<char>::min() << " and "
<< numeric_limits<char>::max();
return 0;
}
Cheers! --M