1. What are binary functors?
2. Why do we need relationships between classes?
3. What will be the output of the following C++ code?
#include <iostream>
#include <utility>
#include <string>
using namespace std;
int main ()
{
pair <int,int> p1(1,2);
pair <int,int> p2(3,4);
cout<<"Pair(first,second) = ("<<p1.first<<","<<p1.second<<")\n";
p1.swap(p2);
cout<<"Pair(first,second) = ("<<p1.first<<","<<p1.second<<")\n";
return 0;
}
#include <iostream>
#include <utility>
#include <string>
using namespace std;
int main ()
{
pair <int,int> p1(1,2);
pair <int,int> p2(3,4);
cout<<"Pair(first,second) = ("<<p1.first<<","<<p1.second<<")\n";
p1.swap(p2);
cout<<"Pair(first,second) = ("<<p1.first<<","<<p1.second<<")\n";
return 0;
}4. What is meant by permutation in c++?
5. Which operators are used in the free store?
6. Which algorithm is used in subtract_with_carry_engine?
7. What will be the output of the following C++ code?
#include<iostream>
#include<iterator>
#include<vector>
using namespace std;
int main()
{
vector<int> ar = { 1, 2, 3, 4, 5 };
vector<int>::iterator ptr = ar.begin();
ptr = next(ptr, 3);
cout << *ptr << endl;
return 0;
}
#include<iostream>
#include<iterator>
#include<vector>
using namespace std;
int main()
{
vector<int> ar = { 1, 2, 3, 4, 5 };
vector<int>::iterator ptr = ar.begin();
ptr = next(ptr, 3);
cout << *ptr << endl;
return 0;
}8. What will be the output of the following C++ code?
#include <iostream>
#include <exception>
using namespace std;
struct MyException : public exception
{
const char * what () const throw ()
{
return "C++ Exception";
}
};
int main()
{
try
{
throw MyException();
}
catch(MyException& e)
{
cout << "Exception caught" << std::endl;
cout << e.what() << std::endl;
}
catch(std::exception& e)
{
}
}
#include <iostream>
#include <exception>
using namespace std;
struct MyException : public exception
{
const char * what () const throw ()
{
return "C++ Exception";
}
};
int main()
{
try
{
throw MyException();
}
catch(MyException& e)
{
cout << "Exception caught" << std::endl;
cout << e.what() << std::endl;
}
catch(std::exception& e)
{
}
}9. What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
vector<int> myvector (5);
fill (myvector.begin(), myvector.begin() + 4, 5);
fill (myvector.begin() + 3,myvector.end() - 2, 8);
for (vector<int> :: iterator it = myvector.begin();
it != myvector.end(); ++it)
cout << ' ' << *it;
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
vector<int> myvector (5);
fill (myvector.begin(), myvector.begin() + 4, 5);
fill (myvector.begin() + 3,myvector.end() - 2, 8);
for (vector<int> :: iterator it = myvector.begin();
it != myvector.end(); ++it)
cout << ' ' << *it;
return 0;
}10. What will be the output of the following C++ code?
#include <iostream>
#include <utility>
using namespace std;
int main ()
{
pair <int,int> p(1,2);
cout<<"Pair(first,second) = ("<<p.first<<","<<p.second<<")\n";
return 0;
}
#include <iostream>
#include <utility>
using namespace std;
int main ()
{
pair <int,int> p(1,2);
cout<<"Pair(first,second) = ("<<p.first<<","<<p.second<<")\n";
return 0;
}Read More Section(C plus plus miscellaneous)
Each Section contains maximum 100 MCQs question on C plus plus miscellaneous. To get more questions visit other sections.
- C plus plus miscellaneous - Section 1
- C plus plus miscellaneous - Section 2
- C plus plus miscellaneous - Section 3
- C plus plus miscellaneous - Section 4
- C plus plus miscellaneous - Section 5
- C plus plus miscellaneous - Section 6
- C plus plus miscellaneous - Section 8
- C plus plus miscellaneous - Section 9
- C plus plus miscellaneous - Section 10
- C plus plus miscellaneous - Section 11
