Free CPP – C++ Certified Professional Programmer Practice Test Question

Free demo downloads

Loading demo links...

Showing 13–15 of 15 questions

Question 13 (Volume B)

What happens when you attempt to compile and run the following code?

#include using namespace std;

int main()

{

cout.setf(ios::oct, ios::basefield); cout<<100<<" "; cout.setf(ios::showbase); cout<<100<<" ";

return 0;

}

Program outputs:

Select an option, then click Submit answer.

  • ○

    144 0144

  • ○

    144 0x64

  • ○

    0x144 0144

  • ○

    0144 100

  • ○

    compilation error

Question 14 (Volume A)

What happens when you attempt to compile and run the following code?

#include

#include

#include #include

using namespace std;

void myfunction(int i) {

cout << " " << i;

}

int main() {

int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 }; deque d1(t, t+10); vector v1(d1.rbegin(), d1.rend()); sort(d1.begin(), d1.end());

swap_ranges(v1.begin(), v1.end(), d1.begin()); for_each(v1.begin(), v1.end(), myfunction); for_each(d1.begin(), d1.end(), myfunction); return 0; }

Program outputs:

Select an option, then click Submit answer.

  • ○

    10 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10

  • ○

    compilation error

  • ○

    1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10

  • ○

    1 2 3 4 5 6 7 8 9 10 1 3 8 7 4 2 6 9 5 10

  • ○

    1 3 8 7 4 2 6 9 5 10 1 2 3 4 5 6 7 8 9 10

Question 15 (Volume B)

What happens when you attempt to compile and run the following code?

#include

#include

#include #include using namespace std; templatestruct Out { ostream & out; Out(ostream & o): out(o){}

void operator() (const T & val ) { out<

};

int main() { char s[]={"qwerty"}; char t1[]={"ert"}; char t2[]={"ERT"}; sort(s, s+6);

cout<

Program outputs:

Select an option, then click Submit answer.

  • ○

    0 0

  • ○

    0 1

  • ○

    1 0

  • ○

    1 1