View Mode
Q: 1
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 }; multiset s1(t,t+10); s1.insert(s1.find(7), 3); for(multiset::iterator i=s1.begin();i!= s1.end(); i++) { cout<<*i<<" "; } return 0; }
Options
Q: 2
What happens when you attempt to compile and run the following code? #include #include #include #include using namespace std; templatestruct Out { ostream & out; Out(ostream & o): out(o){} void operator() (const T & val ) { out<<val<<" "; } }; struct Add : public binary_function { int operator() (const int & a, const int & b) const { return a+b; } }; int main() { int t[]={1,2,3,4,5,6,7,8,9,10}; deque d1(t, t+10); deque d2(10); transform(d1.begin(), d1.end(), d2.begin(), bind2nd(Add(), 1)); for_each(d2.rbegin(), d2.rend(), Out(cout));cout<<endl; return 0; } Program outputs:
Options
Q: 3
What happens when you attempt to compile and run the following code? #include using namespace std; template void f(A a) { cout<<1<<endl; } void f(int a) { cout<<2<<endl; } int main() { int a = 1; f(a); return 0; }
Options
Q: 4
What will be output of the program when you attempt to compile and run the following code? #include #include #include #include using namespace std; int main(){ int second[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 }; string first[] = {"three", "four", "two", "one", "six","five", "seven", "nine","eight","zero"}; multimap m; for(int i=0; i<10; i++) { m.insert(pair(second[i],first[i])); } m[0]="ten"; m.insert(pair(1,"eleven")); for(multimap::iterator i=m.begin();i!= m.end(); i++) { cout<second<<" "; } return 0; }
Options
Q: 5
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<set::iterator, vector::iterator > resultSet = equal(s1.begin(), s1.end(), v1.begin()); cout<<*resultSet.first<<" "<<*resultSet.second<<endl; return 0; } Program outputs:
Options
Q: 6
What happens when you attempt to compile and run the following code? #include #include using namespace std; template class A { T_v; public: A() {} A(T v): _v(v){} T getV() { return _v; } void add(T & a) { _v+=a; } void add(string & a) { _v.insert(0, a); } }; int main() { Aa("Hello"); string s(" world!"); a.add(s); cout << a.getV() <<endl; return 0; }
Options
Q: 7
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() { int t[]={20, 30, 10, 20, 30, 10, 20, 30, 10, 20}; deque d1(t, t+10); sort(d1.begin(), d1.end(), greater()); pair<deque ::iterator, deque::iterator > result = equal_range(d1.begin(), d1.end(), B(20), greater()); for_each(result.first, result.second, Out(cout));cout<<endl; return 0; } Program outputs:
Options
Q: 8
What will happen when you attempt to compile and run the code below, assuming that you enter the following sequence: 1.1 2.2 3.3? #include #include using namespace std; int main () { int a,b,c; cin>>a>>b>>c; cout<<a<<b<<c<<endl; return 0; } Program will output:
Options
Q: 9
What happens when you attempt to compile and run the following code? #include #include #include using namespace std; bool compare(int a, int b) { return a == b; } int main () { int t[] = {1,2,3,4,5,1,2,3,4,5}; vector v (t,t+10); vector::iterator it = v.begin(); int m1[] = {1, 2, 3}; while ( (it = find_first_of (it, v.end(), m1, m1+3)) != v.end()) { cout<<it?v.begin()<<" "; } cout<< endl; return 0; }
Options
Q: 10
What will happen when you attempt to compile and run the following code? #include using namespace std; class C { public: int _c; C():_c(0){} C(int c) { _c = c;} C operator+=(C & b) { C tmp; tmp._c = _c+b._c; return tmp; } }; 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(2); Aa (5); Cc; a.add(c); cout << a.getV() <<endl; return 0; }
Options
Question 1 of 20 · Page 1 / 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