View Mode
Q: 11
What happens when you attempt to compile and run the following code? #include #include int main () { std::vectorv1; for(int i = 10; i>0; i??) { v1.push_back(i); } std::vector::iterator it = v1.begin(); int sum = 0; while(it != v1.end()) { sum+=it++; } std::cout<<*v1.erase(v1.begin(),v1.end()?3)<<" "<<sum <<std::endl; return 0; }
Options
Q: 12
What happens when you attempt to compile and run the following code? #include #include #include #include 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;} templatestruct Out { ostream & out; Out(ostream & o): out(o){} void operator() (const T & val ) { out<<val<<" "; } }; int main() { B t[]={8, 10, 5, 1, 4, 6, 2, 7, 9, 3}; B t1[]={B(1),B(2),B(3),B(4)}; deque d1(t, t+10); set s1(t, t+10); sort(d1.begin(), d1.end()); cout<<includes(d1.begin(),d1.end(), t1,t1+4)<<" "<<includes(s1.begin(),s1.end(), t1,t1+4) <<endl; return 0; } Program outputs:
Options
Q: 13
What happens when you attempt to compile and run the following code? #include #include using namespace std; int main() { int t[] = { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 }; string s[] = { "one", "one", "two", "two", "three","three", "four", "four", "five", "five"}; map m; for (int i = 0; i < 10; i++) { m.push_back(pair(t[i], s[i])); } for (map::iterator i = m.begin(); i != m.end(); i++) { cout <first << " "; } return 0; }
Options
Q: 14
What happens when you attempt to compile and run the following code? #include #include using namespace std; int main() { int t[] = { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 }; string s[] = { "one", "one", "two", "two", "three","three", "four", "four", "five", "five"}; multimap m; for (int i = 0; i < 10; i++) { m.push_back(pair(t[i], s[i])); } for (multimap::iterator i = m.begin(); i != m.end(); i++) { cout <first << " "; } return 0; }
Options
Q: 15
What happens when you attempt to compile and run the following code? #include #include #include #include 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 v1(t, t + 15); deque d1(u, u + 15); pair<deque::iterator, vector::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:
Options
Q: 16
What happens when you attempt to compile and run the following code? #include #include #include using namespace std; void print(int v) { cout<<v<<" "; } struct Sequence { int start; Sequence(int start):start(start){} int operator()() { return start++; } }; int main() { vector v1(10); generate_n(v1.begin(), 10, Sequence(1)); for_each(v1.begin(), v1.end(), print); cout<<endl; return 0; } Program outputs:
Options
Q: 17
What happens 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; multiset 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<<endl; return 0; }
Options
Q: 18
What happens when you attempt to compile and run the following code? Choose all that apply. #include #include using namespace std; int main () { vectorv1(10, 3); v1.push_back(3); cout<<v1.capacity()<<" "<< v1.size()<<endl; return 0; }
Options
Q: 19
What happens when you attempt to compile and run the following code? #include #include #include using namespace std; int main () { listl1; dequed1; for(int i=0; i<5; i++) { l1.push_back(i);l1.push_front(i); d1.push_back(i);d1.push_front(i); } for(int i=0; i<d1.size(); i++) { cout<<d1[i]<<" "<<l1[i]<<" "; } cout<<endl; return 0; }
Options
Q: 20
What happens when you attempt to compile and run the following code? #include #include #include using namespace std; int main(){ int t[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 }; vectorv(t, t+10); multiset s1(v.begin(),v.end()); s1.insert(v.begin(),v.end()); pair<multiset::iterator,multiset::iterator> range; range = s1.equal_range(6); while (range.first != range.second) { cout<<*range.first<<" "; range.first++; } return 0; }
Options
Question 11 of 20 · Page 2 / 2

Premium Access Includes

  • Quiz Simulator
  • Exam Mode
  • Progress Tracking
  • Question Saving
  • Flash Cards
  • Drag & Drops
  • 3 Months Access
  • PDF Downloads
Get Premium Access
Scroll to Top

FLASH OFFER

Days
Hours
Minutes
Seconds

avail 10% DISCOUNT on YOUR PURCHASE