21. Which container can have the same keys?
22. What is the use of no linkage?
23. What will be the output of the following C++ code?
#include <iostream>
#include <map>
using namespace std;
int main ()
{
map<char, int> mymap;
map<char, int> :: iterator it;
mymap['b'] = 100;
mymap['a'] = 200;
mymap['c'] = 300;
for (map<char, int> :: iterator it = mymap.begin(); it != mymap.end(); ++it)
cout << it -> first << " => " << it -> second << '\n';
return 0;
}
#include <iostream>
#include <map>
using namespace std;
int main ()
{
map<char, int> mymap;
map<char, int> :: iterator it;
mymap['b'] = 100;
mymap['a'] = 200;
mymap['c'] = 300;
for (map<char, int> :: iterator it = mymap.begin(); it != mymap.end(); ++it)
cout << it -> first << " => " << it -> second << '\n';
return 0;
}24. Pick out the correct objects about the instantiation of output stream.
25. Which keyword is used for the template?
26. What will be the output of the following C++ code?
#include <iostream>
#include <deque>
using namespace std;
int main ()
{
unsigned int i;
deque<int> mydeque;
deque<int> :: iterator it;
mydeque.push_back ( 100 );
mydeque.push_back ( 200 );
mydeque.push_back ( 300 );
for (it = mydeque.begin(); it != mydeque.end(); ++it)
mydeque.clear();
cout << ' ' << *it;
}
#include <iostream>
#include <deque>
using namespace std;
int main ()
{
unsigned int i;
deque<int> mydeque;
deque<int> :: iterator it;
mydeque.push_back ( 100 );
mydeque.push_back ( 200 );
mydeque.push_back ( 300 );
for (it = mydeque.begin(); it != mydeque.end(); ++it)
mydeque.clear();
cout << ' ' << *it;
}27. What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool myfunction (int i,int j)
{
return (i < j);
}
int main ()
{
int myints[] = {9, 8, 7, 6};
vector<int> myvector (myints, myints + 4);
partial_sort (myvector.begin(), myvector.begin() + 2, myvector.end());
partial_sort (myvector.begin(), myvector.begin() + 2, myvector.end(),
myfunction);
for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
cout << ' ' << *it;
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool myfunction (int i,int j)
{
return (i < j);
}
int main ()
{
int myints[] = {9, 8, 7, 6};
vector<int> myvector (myints, myints + 4);
partial_sort (myvector.begin(), myvector.begin() + 2, myvector.end());
partial_sort (myvector.begin(), myvector.begin() + 2, myvector.end(),
myfunction);
for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
cout << ' ' << *it;
return 0;
}28. What will be the output of the following C++ code?
#include <iostream>
#include <complex>
using namespace std;
int main()
{
complex <double> cn(3.0, 4.0);
cout<<sin(cn)<<endl;
return 0;
}
#include <iostream>
#include <complex>
using namespace std;
int main()
{
complex <double> cn(3.0, 4.0);
cout<<sin(cn)<<endl;
return 0;
}29. Which of the following gives the name of the program if the second parameter to the main fucntion is char **argv?
30. What will be the output of the following C++ code?
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << numeric_limits<float> :: digits10 << endl;
cout << numeric_limits<double> :: digits10 << endl;
float f = 99999999;
cout.precision ( 10 );
cout << f << endl;
}
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << numeric_limits<float> :: digits10 << endl;
cout << numeric_limits<double> :: digits10 << endl;
float f = 99999999;
cout.precision ( 10 );
cout << f << endl;
}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 7
- C plus plus miscellaneous - Section 8
- C plus plus miscellaneous - Section 9
- C plus plus miscellaneous - Section 11
