1. Home
  2. C++ Institute
  3. CPP Exam Questions

Free CPP Exam Questions - C++ Institute CPP Exam

C++ Institute CPP Exam

C++ Institute CPP Exam - Prepare from Latest, Not Redundant Questions!

Many candidates desire to prepare their C++ Institute CPP exam with the help of only updated and relevant study material. But during their research, they usually waste most of their valuable time with information that is either not relevant or outdated. Study4Exam has a fantastic team of subject-matter experts that make sure you always get the most up-to-date preparatory material. Whenever there is a change in the syllabus of the CPP - C++ Certified Professional Programmer Exam , our team of experts updates CPP questions and eliminates outdated questions. In this way, we save you money and time.

C++ Institute CPP Exam Sample Questions:

Q1.

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

#include

using namespace std;

class C {};

template

class A {

T_v;

public:

A() {}

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

T getV() { return _v; }

void add(T a) { _v+=a; }

};

int main()

{

A b;

Aa;

a.add(C());

cout << b.getV() <

return 0;

}

Q2.

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

#include

#include

#include

using namespace std;

class A {

int a;

public:

A(int a) : a(a) {}

int getA() const { return a; } void setA(int a) { this?>a = a; }

bool operator==(A & b) { return a == b.a; }

};

struct Compare{

bool operator()(const A & a, const A & b) {return a.getA()==b.getA();};

};

int main () {

int t[] = {1,2,3,4,5,1,2,3,4,5};

vector v (t,t+10);

vector::iterator it;

A m1[] = {A(1), A(2), A(3)};

it = find_end (v.begin(), v.end(), m1, m1+3, Compare());

cout << "Found at position: " << it?v.begin() << endl;

return 0;

}

Q3.

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

#include

#include

#include

#include

using namespace std;

int main() {

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

vector v1(t, t + 15);

set s1(t, t + 15);

pair::iterator, vector::iterator > resultSet = equal(s1.begin(), s1.end(), v1.begin());

cout<<*resultSet.first<<" "<<*resultSet.second<

return 0;

}

Program outputs:

Q4.

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[] = { 1, 5, 2, 5, 2, 4, 4, 3, 3, 1 };

vector v1(t, t+10);

set s1(t, t+10);

replace(v1.begin(), v1.end(), 1, 10);

replace(s1.begin(), s1.end(), 1, 10);

for_each(v1.begin(), v1.end(), myfunction);

return 0;

}

Program outputs:

Q5.

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

#include

#include

#include

using namespace std;

template void print(T start, T end) {

while (start != end) {

std::cout << *start << " "; start++;

}

}

int main(){

vectorv;

set s;

for(int i=10; i>0; i??) {

v.push_back(i);

s.push_back(i);

}

print(v.begin(), v.end()); print(s.begin(), s.end());cout<

return 0;

}

The output will be:

Solutions:
Question: 1 Answer: B
Question: 2 Answer: A
Question: 3 Answer: D
Question: 4 Answer: C
Question: 5 Answer: D
Disscuss C++ Institute CPP Topics, Questions or Ask Anything Related

Currently there are no comments in this discussion, be the first to comment!