< previous page page_127 next page >

Page 127
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. fabs(-9.1)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b. sqrt(49.0)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
c. 3 * int(7.8) + 3
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
d. pow(4.0, 2.0)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
e. sqrt(float(3 * 3 + 4 * 4))
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
f. sqrt(fabs(-4.0) + sqrt(25.0))
7. Show precisely the output of the following C++ program. Use a to indicate each blank.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
#include <iostream.h>
#include <iomanip.h>     // For setw()

int main()
{
    char ch;
    int   n;
    float y;

    ch = 'A';
    cout < ch;
    ch = 'B';
    cout < ch < endl;
    n = 413;
    y = 21.8;
    cout < setw(5) < n <  is the value of n < endl;
    cout < setw(7) < y <  is the value of y < endl;
    return 0;
}
8. Given that x is a float variable and x = 14.3827, show the output of each statement below. Use a to indicate each blank.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. cout < x is < setw(5) < setprecision(2) < x;
b. cout < x is < setw(8) < setprecision(2) < x;
c. cout < x is < setw(0) < setprecision(2) < x;
d. cout < x is < setw(7) < setprecision(3) < x;
9. Show precisely what is output by the following statement.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
cout < A rolling < endl
     < stone < endl < endl
     < gathers < endl
     < endl < endl < endl < no
     < moss < endl;

 
< previous page page_127 next page >