Online Access Free CPP Exam Questions

Exam Code:CPP
Exam Name:C++ Certified Professional Programmer
Certification Provider:C++ Institute
Free Question Number:230
Posted:Nov 27, 2026
Rating
100%

Question 1

What happens when you attempt to compile and run the following code?
#include <vector>
using namespace std;
int main ()
{
std::vector<int>v1;
v1.push_back(10);
return 0;
}

Question 2

What happens when you attempt to compile and run the following code?
#include <iostream>
#include <algorithm>
#include <set>
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; }
operator int() const {return a;}
};
int main () {
int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};
set<A> s (t,t+15);
cout<<equal(s.begin(), s.end(), t)<<endl;
return 0;
}
Program outputs:

Question 3

What happens when you attempt to compile and run the following code?
# include <iostream>
# include <map>
# include <string>
using namespace std;
int main(){
int second[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 10 };
string first[] = {"three", "four", "two", "one", "six","five", "seven", "nine","eight"," ten"}; map<int,string> m;
for(int i=0; i<10; i++) {
m.insert(pair<int,string>(second[i],first[i]));
}
if (m[11] == "eleven") {
cout<<"eleven ";
}
for(map<int, string>::iterator i=m.begin();i!= m.end(); i++) {
cout<<i?>second<<" ";
}
cout<<m.size();
return 0;
}

Question 4

What happens when you attempt to compile and run the following code?
include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
using namespace std;
int main() {
int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };
vector<int> v1(t, t + 10);
deque<int> d1(t, t + 10);
set<int> s1(t, t + 10);
cout<<find(v1.begin(), v1.end(), 6)<<" "<<find(d1.begin(), d1.end(), 6)<<"
"<<find(s1.begin(), s1.end(), 6);
return 0;
}

Question 5

What will happen when you attempt to compile and run the following code?
#include <deque>
#include <vector>
#include <iostream>
using namespace std;
class A
{
int a;
public:
A(int a) {this?>a = a; c++;}
~ A() { c??;}
static int c;
};
int A::c(0);
int main ()
{
A t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8 , 9};
vector<A>v1(t, t+10);
deque<A>d1(v1.begin(), v1.end());
deque<A> d2;
d2 = d1;
cout<<A::c<< endl;
return 0;
}
How many objects of type A will be created:

Add Comments

Your email address will not be published. Required fields are marked *

insert code
Type the characters from the picture.