Free CPP Exam Braindumps (page: 24)

Page 24 of 58

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

#include <deque>
#include <vector>
#include <iostream>
using namespace std;
int main ()
{
vector<int> v1;
deque<int> d1;
for(int i=0; i<5; i++)
{
v1.push_back(i);v1.push_front(i);
d1.push_back(i);d1.push_front(i);
}
for(int i=0; i<d1.size(); i++)
{
cout<<d1[i]<<" "<<v1[i]<<" ";
}
cout<<endl;
return 0;
}

What will be its output:

  1. 4 4 3 3 2 2 1 1 0 0 0 0 1 1 2 2 3 3 4 4
  2. runtime exception
  3. compilation error due to line 11
  4. compilation error due to line 12

Answer(s): C



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

#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
using namespace std;
bool identical(int a, int b) {
return b == 2*a?true:false;
}
int main() {
int t[] = {1,2,3,2,3,5,1,2,7,3,2,1,10, 4,4,5};
int u[] = {2,4,6,4,6,10,2,4,14,6,4,2,20,8,8,5};
vector<int> v1(t, t + 15);
deque<int> d1(u, u + 15);

pair<deque<int>::iterator, vector<int>::iterator > result;
result = mismatch(d1.begin(), d1.end(), v1.begin(), identical); //Line I
if (result.first == d1.end() && result.second == v1.end()) { //Line II
cout<<"Identical\n";
} else {
cout<<"Not identical\n";
}
return 0;
}

Program outputs:

  1. Identical
  2. Not identical
  3. compilation error at line marked I
  4. compilation error at line marked II

Answer(s): B



What will happen when you attempt to compile and run the code below, assuming that you enter the following sequence: true false<enter>?

#include <iostream>
#include <string>
using namespace std;

int main ()
{
bool a,b;
cin>>boolalpha>>a>>b;
cout<<a<<b<<endl;
return 0;
}

Program will output:

  1. truefalse
  2. true0;
  3. 1false
  4. 10
  5. none of these

Answer(s): D



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

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
class B { int val;
public:
B(int v):val(v){}
int getV() const {return val;} bool operator < (const B & v) const { return val<v.val;} };
ostream & operator <<(ostream & out, const B & v) { out<<v.getV(); return out;}
template<class T>struct Out {
ostream & out;
Out(ostream & o): out(o){}
void operator() (const T & val ) { out<<val<<" "; } };
int main() {
int t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3};
vector<B> v1(t, t+10);
sort(v1.begin(), v1.end(), greater<B>());
for_each(v1.begin(), v1.end(), Out<B>(cout));cout<<endl;
return 0;
}

Program outputs:

  1. 8 10 5 1 4 6 2 7 9 3
  2. 1 2 3 4 5 6 7 8 9 10
  3. compilation error
  4. 10 9 8 7 6 5 4 3 2 1

Answer(s): C



Page 24 of 58



Post your Comments and Discuss C++ Institute CPP exam with other Community members:

Barbara commented on October 07, 2024
good content!
UNITED STATES
upvote

Adekunle commented on October 07, 2024
I really appreciate the owner of this site. I took my Exam today and I passed. Thanks alot
Anonymous
upvote

mogoi commented on October 07, 2024
simple question
Anonymous
upvote

iyanu commented on October 07, 2024
please how do we download the premium version
UNITED STATES
upvote

okiki commented on October 07, 2024
i cant download the premium version.. what to do please?
UNITED STATES
upvote

lky commented on October 07, 2024
thanks. very food!!
KOREA REPUBLIC OF
upvote

lky commented on October 07, 2024
thanks. this exam is helping to me.
KOREA REPUBLIC OF
upvote

Mano commented on October 07, 2024
Thank you very much for this study material. I found it very useful.
Japan
upvote

John commented on October 07, 2024
This exam dump is not bad at all. Exam itself is hard but I passed.
Netherlands
upvote

Mogi commented on October 07, 2024
simple question
Anonymous
upvote

mOGI commented on October 07, 2024
SIMPLE QUESTIONS
Anonymous
upvote

Ajinkya commented on October 07, 2024
Helped me to crack
Anonymous
upvote

Syama Sundar commented on October 07, 2024
preparing the exam and for testing your questions is helping very much . Really need the other questions to validate my ability.
AUSTRALIA
upvote

Syam commented on October 07, 2024
fantastic support for certification seekers
AUSTRALIA
upvote

mogi commented on October 07, 2024
Good worksimple question but certification have tough questions
Anonymous
upvote

Julian commented on October 07, 2024
Passed and got a 92% in this exam.
Anonymous
upvote

Tsholofelo commented on October 07, 2024
Tricky question
Anonymous
upvote

Gowtham commented on October 06, 2024
Great questions
UNITED STATES
upvote

Brook commented on October 06, 2024
Great While free AZ-900 exam braindumps might seem tempting, they often come with risks like outdated information or inaccuracies. Investing in reliable study materials, like those from this site ensures you get the latest and most accurate content to help you succeed.
Anonymous
upvote

Yogi commented on October 06, 2024
Simple quesitons
CANADA
upvote

Anderson commented on October 06, 2024
Finally passed this exam. I am certified now and ready for a promotion.
Brazil
upvote

NOOR commented on October 06, 2024
I want to pass my CIA Exam P2 withing the next 2weeks, can I get help?
UNITED ARAB EMIRATES
upvote

Gevo commented on October 05, 2024
First exam is passed. Studying and preparation for second exam now. I purchased 2 study guides with 50% discount. Goo deal.
Singapore
upvote

Ama commented on October 05, 2024
Dump PDF OK
Anonymous
upvote

Marv commented on October 05, 2024
This is Great!
Anonymous
upvote

Aaa commented on October 05, 2024
Best Practice
Anonymous
upvote

sadai commented on October 05, 2024
I really apricate this helpful test
Anonymous
upvote

sadai commented on October 04, 2024
I do not know to say thanks it is really useful
Anonymous
upvote

sadai commented on October 04, 2024
it was really useful thank you so much
Anonymous
upvote

sadai commented on October 04, 2024
Hi it was really helpful for me to improve my mind
Anonymous
upvote

Mohammed Haque commented on October 04, 2024
very useful site for exam prep
UNITED STATES
upvote

Melvin commented on October 04, 2024
Educational
Anonymous
upvote

NJ commented on October 04, 2024
Good Study Material
UNITED STATES
upvote

Tsholofelo commented on October 04, 2024
Mostly challenging question
Anonymous
upvote