61. What will be the output of the following C++ code?
#include <iostream>
#include <Valarray>
using namespace std;
int main()
{
Valarray<int> varr = { 1, 2, 3, 4, 5 };
for (int &x: varr) cout << x << " ";
cout<<endl;
varr = varr.shift(2);
for (int &x: varr) cout << x << " ";
return 0;
}
#include <iostream>
#include <Valarray>
using namespace std;
int main()
{
Valarray<int> varr = { 1, 2, 3, 4, 5 };
for (int &x: varr) cout << x << " ";
cout<<endl;
varr = varr.shift(2);
for (int &x: varr) cout << x << " ";
return 0;
}
62. What function will be called when we have an uncaught exception?
63. What will be the output of the following C++ code?
#include <iostream>
#include <vector>
#include <forward_list>
using namespace std;
int main()
{
forward_list<int> fl1 = {1,2,3,4,5};
for (int&c : fl1)
cout << c << " ";
cout<<endl;
fl1.remove_if([](int x){ return x > 3;});
for (int&c : fl1)
cout << c << " ";
cout<<endl;
return 0;
}
#include <iostream>
#include <vector>
#include <forward_list>
using namespace std;
int main()
{
forward_list<int> fl1 = {1,2,3,4,5};
for (int&c : fl1)
cout << c << " ";
cout<<endl;
fl1.remove_if([](int x){ return x > 3;});
for (int&c : fl1)
cout << c << " ";
cout<<endl;
return 0;
}
64. What will be the output of the following C++ code?
#include <iostream>
#include <valarray>
using namespace std;
int main()
{
valarray<int> varr = { 10, 2, 20, 1, 30 };
cout<<"Sum of array: "<<varr.sum();
return 0;
}
#include <iostream>
#include <valarray>
using namespace std;
int main()
{
valarray<int> varr = { 10, 2, 20, 1, 30 };
cout<<"Sum of array: "<<varr.sum();
return 0;
}
65. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class Base
{
public:
Base ( )
{
cout << "1" << endl;
}
~Base ( )
{
cout << "2" << endl;
}
};
class Derived : public Base
{
public:
Derived ( )
{
cout << "3" << endl;
}
~Derived ( )
{
cout << "4" << endl;
}
};
int main( )
{
Derived x;
}
#include <iostream>
using namespace std;
class Base
{
public:
Base ( )
{
cout << "1" << endl;
}
~Base ( )
{
cout << "2" << endl;
}
};
class Derived : public Base
{
public:
Derived ( )
{
cout << "3" << endl;
}
~Derived ( )
{
cout << "4" << endl;
}
};
int main( )
{
Derived x;
}
66. What will be the output of the following C++ code?
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
bitset<8> b1(95);
bitset<8> b2 = b1 << 3;
cout<<b2;
}
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
bitset<8> b1(95);
bitset<8> b2 = b1 << 3;
cout<<b2;
}
67. What is the main feature of locale in C++?
68. Elements in STL heap are removed in . . . . . . . .
69. What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
vector<int> myvector;
for (int i = 1; i < 5; ++i)
myvector.push_back(i);
rotate(myvector.begin(), myvector.begin() + 3, myvector.end( ));
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;
for (int i = 1; i < 5; ++i)
myvector.push_back(i);
rotate(myvector.begin(), myvector.begin() + 3, myvector.end( ));
for (vector<int> :: iterator it = myvector.begin();
it != myvector.end(); ++it)
cout << ' ' << *it;
return 0;
}
70. What are command line arguments?
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 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 10
- C plus plus miscellaneous - Section 11