Problems on your own

Try to figure out what the values of the variables s and t are in the following code fragment:

int s = 024;
int t = 0x16;

In this code fragment, try and figure out what the display output will be:

int m = 13;
int n = 3;
float x = 2.0;
double z = 5.0;
char a = 'E';         // 'A' = 65
char b = 'a';         // 'a' = 97

cout <<   m / n          << endl;
cout <<   m % n          << endl;
cout <<   n + x          << endl;
cout <<   z / n          << endl;
cout <<   int(z / x)     << endl;
cout <<   a              << endl;
cout <<   a + 2          << endl;
cout <<   char(b + 3)    << endl;
cout <<   'b' + 1        << endl;
cout <<   "b + 1"        << endl;

Write the above code fragments into a complete program to verify your predictions.

Remember, BeOS will automagically adjust the display of floats for you, so if a float is even, such as 5.0, it will display as 5 by default. If you wish to verify that it is displayed as a float, add the following lines of code prior to using cout:

cout.setf(ios::showpoint);
cout.precision(3);

Also include the iomanip header in your code (#include <iomanip>).

Now we will go on to control structures.