Limited-Time Offer: Enjoy 60% Savings! - Ends In 0d 00h 00m 00s Coupon code: 60OFF
Welcome to QA4Exam
Logo

- Trusted Worldwide Questions & Answers

Most Recent C++ Institute CPP Exam Questions & Answers


Prepare for the C++ Institute CPP - C++ Certified Professional Programmer Exam exam with our extensive collection of questions and answers. These practice Q&A are updated according to the latest syllabus, providing you with the tools needed to review and test your knowledge.

QA4Exam focus on the latest syllabus and exam objectives, our practice Q&A are designed to help you identify key topics and solidify your understanding. By focusing on the core curriculum, These Questions & Answers helps you cover all the essential topics, ensuring you're well-prepared for every section of the exam. Each question comes with a detailed explanation, offering valuable insights and helping you to learn from your mistakes. Whether you're looking to assess your progress or dive deeper into complex topics, our updated Q&A will provide the support you need to confidently approach the C++ Institute CPP exam and achieve success.

The questions for CPP were last updated on Dec 20, 2024.
  • Viewing page 1 out of 46 pages.
  • Viewing questions 1-5 out of 228 questions
Get All 228 Questions & Answers
Question No. 1

Given three files: class.h, class.cpp and main.cpp containing small C++ project, which sentences are TRUE if you attempt to compile and run the program? Assume that the whole compiling environment is properly set.

// File: main.cpp

#include

#include "class.h"

using namespace std;

int main()

{

A a;

cout << a.getV() << endl;

return 0;

}

//File: class.h

#ifndef _CLASS_

#define _CLASS_

template

class A {

T_v;

public:

A() {}

A(T v);

T getV();

};

#endif

//File: class.cpp

#include "class.h"

template

A::A(T v):_v(v) {}

template

T A::getV() { return _v; }

Show Answer Hide Answer
Correct Answer: D

Question No. 2

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

#include

#include

#include

using namespace std;

templatestruct Out {

ostream & out;

Out(ostream & o): out(o){}

void operator()(const T & val ) {

out<

}

};

struct Sequence {

int start;

Sequence(int start):start(start){}

int operator()() { return 10*(1+(start++ %3)); } };

int main() {

vector v1(10);

vector v2(10);

generate(v1.begin(), v1.end(), Sequence(1));

sort(v1.rbegin(), v1.rend());

unique_copy(v1.begin(),v1.end(), v2.begin());

for_each(v2.begin(), v2.end(), Out(cout) );cout<

return 0;

}

Program outputs:

Show Answer Hide Answer
Correct Answer: B

Question No. 3

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

#include

#include

#include

using namespace std;

int main() {

int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };

map m;

for(int i=0; i < 10; i++) {

m[i]=t[i];

}

map::iterator it = find(m.begin(), m.end(), 5);

cout<first;

return 0;

}

Program outputs:

Show Answer Hide Answer
Correct Answer: D

Question No. 4

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

#include

#include

#include

using namespace std;

class B { int val;

public:

B(int v):val(v){} B(){}

int getV() const {return val;} };

ostream & operator <<(ostream & out, const B & v) { out<

templatestruct Out {

ostream & out;

Out(ostream & o): out(o){}

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

int main() {

int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3};

deque d1(t, t+10);

deque::iterator it = lower_bound(d1.begin(), d1.end(), 4);

for_each(it, d1.end(), Out(cout));cout<

return 0;

}

Program outputs:

Show Answer Hide Answer
Correct Answer: D

Question No. 5

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

#include

#include

#include

using namespace std;

templatestruct Out {

ostream & out;

Out(ostream & o): out(o){}

void operator()(const T & val ) {

out<

struct Sequence {

int start;

Sequence(int start):start(start){}

int operator()() {

return start++; } };

int main() {

vector v1(10);

vector v2(10);

generate(v1.begin(), v1.end(), Sequence(1));

reverse_copy(v1.begin(),v1.end(), v2.rbegin());

sort(v2.begin(), v2.end(), less_equal());

for_each(v2.begin(), v2.end(), Out(cout) );cout<

return 0;

}

Program outputs:

Show Answer Hide Answer
Correct Answer: A

Unlock All Questions for C++ Institute CPP Exam

Full Exam Access, Actual Exam Questions, Validated Answers, Anytime Anywhere, No Download Limits, No Practice Limits

Get All 228 Questions & Answers