C++ Manipulators - placement practice test

C++ Manipulators - placement practice test


1. ______________are used to format the data display in CPP?

a. Iterators
b. Punctuators
c. Manipulators
d. Allocators
View Answer / Hide Answer

ANSWER: c. Manipulators




2. Which of the followings is/are not a manipulator/s ?

1. flush
2. base
3. ends
4. oct
5. bin
6. skipws

a. Only 1, 6
b. Only 1,4,6
c. Only 1,3,6
d. Only 2,5
View Answer / Hide Answer

ANSWER: d. Only 2,5




3. Which of the following manipulator is used for the representing octal equivalent of a given decimal number ?

a. oct
b. setbase(8)
c. tobase(8)
d. both a and b
d. all a, b, c
View Answer / Hide Answer

ANSWER: d. both a and b




4. ___________ header file is used for manipulators.

a. < iomanipulator.h>
b. < stdiomanip.h>
c. < stdmanip.h>
d. < iomanip.h>
View Answer / Hide Answer

ANSWER: d. < iomanip.h>




5. Predict the output:

int x = 786;
cout <<setfill(‘*’)<<setw(6)<<x;

a. 786***
b. **786
c. ***786
d. ******
View Answer / Hide Answer

ANSWER: c. ***786
Explanation:: When set() manipulator is used, then output is right justified. So. Out of 6 width, 3 are used by variable x and remaining 3 width (Spaces) are filled with char * due to

setfill().




6. Predict the output:

float x= 3.1496;
cout<<setpricision(2)<<x;

a. 3.14
b. 3.15
c. 3.00
d. None of these
View Answer / Hide Answer

ANSWER: d. None of these
Explanation: setprecision(int ) is predefined manipulator. Due to spelling mistake here, compiler will generate error.



Post your comment

    Discussion

  • rwuktfqxzp -qylhzotie (10/03/23)
  • http://dokobo.ru/uhy-careerride.com-nja.xml
  • RE: C++ Manipulators - placement practice test -Eric Cortez (07/31/14)
  • should be

    float x= 3.1496;
    cout << setprecision(2) << x;