What will be the output of the following C++ code?
#include <iostream>
using namespace std;
template <typename T, typename U>
void squareAndPrint(T x, U y)
{
cout << x << x * x << endl;
cout << y << " " << y * y << endl;
};
int main()
{
int ii = 2;
float jj = 2.1;
squareAndPrint<int, float>(ii, jj);
}A. 23
2.1 4.41
B. 24
2.1 4.41
C. 24
2.1 3.41
D. 2.1 3.41
Select an option to see the answer and solution.
Which of the following is a Non-modifying Sequence Operation?
A. swap()
B. transform()
C. remove()
D. search()
Select an option to see the answer and solution.
What will be the output of the following C++ code?
#include <iostream>
#include <list>
using namespace std;
int main ()
{
list<int> mylist;
list<int> :: iterator it1, it2;
for (int i = 1; i < 10; ++i) mylist.push_back(i * 1);
it1 = it2 = mylist.begin();
advance (it2, 6);
++it1;
it1 = mylist.erase (it1);
it2 = mylist.erase (it2);
++it1;
--it2;
mylist.erase (it1, it2);
for (it1 = mylist.begin(); it1 != mylist.end(); ++it1)
cout << ' ' << *it1;
return 0;
}A. 1 3 6
B. 8 9
C. 1 3 6 8 9
D. 4 6 8 9
Select an option to see the answer and solution.
What is the use of is_same() function in C++?
A. To check if a variable is array type or not
B. To check whether two variables have the same characteristics
C. To check if two variable is of array type or not
D. To check whether two variables are different or not
Select an option to see the answer and solution.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class Base
{
public:
Base(){}
~Base(){}
protected:
private:
};
class Derived:public Base
{
public:
Derived(){}
Derived(){}
private:
protected:
};
int main()
{
cout << "The program exceuted" << endl;
}A. The program executed
B. Error
C. Runtime error
D. program exceuted
Select an option to see the answer and solution.
What type of reference should be used in vector arithmetic?
A. dynamic
B. const
C. both dynamic & const
D. static
Select an option to see the answer and solution.
What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
using namespace std;
int main ()
{
cout << min(2, 1) << ' ';
cout << min('m','m') << '\n';
return 0;
}A. Error
B. Runtime error
C. 1 m
D. 5 m
Select an option to see the answer and solution.
Which value is pointed out first in heap?
A. Lowest value
B. Highest value
C. First value
D. Third value
Select an option to see the answer and solution.
What will be the output of the following C++ code?
#include <iostream>
#include<type_traits>
using namespace std;
class Base
{
public:
void function1() {};
void function2() {};
};
int main()
{
Base b;
cout<<sizeof(b);
return 0;
}Select an option to see the answer and solution.
Which of the following(s) is/are the correct way of assigning values to a forward_list f?
A. f.assign({1,2,3,4,5})
B. f.assign(10,5)
C. both f.assign({1,2,3,4,5}) and f.assign(10,5)
D. f.assign(1,1,1,1)
Select an option to see the answer and solution.
What is meant by type_info?
A. Used to hold the type information returned by the typeid operator
B. Used to hold the type information returned by the dynamic_cast
C. Used to hold the type information returned by the static_cast
D. Used to hold the type information returned by the static_id
Select an option to see the answer and solution.
What will be the output of the following C++ code?
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
vector<int> v(10, 2);
if (all_of(v.cbegin(), v.cend(), [](int i){ return i % 2 == 0; }))
{
cout << "All numbers are even\n";
}
else
{
cout << "All numbers are not even\n";
}
return 0;
}A. All numbers are even
B. All numbers are not even
C. Error
D. Segmentation fault
Select an option to see the answer and solution.
What will be the output of the following C++ code?
#include <iostream>
#include <limits>
using namespace std;
int main( )
{
cout << numeric_limits<float> :: min_exponent << endl;
}Select an option to see the answer and solution.
What are Engine Adaptors?
A. Class template that adopts a pseudo-random number generator engine
B. Class template that adopts a pseudo-random number generator engine to produce numbers with a given numbers of bits
C. Random number engine that generates pseudo-random numbers
D. Mersenne Twister 19937 generator generating 32-bit true random number
Select an option to see the answer and solution.
Which is used to check the error in the block?
A. try
B. throw
C. catch
D. handler
Select an option to see the answer and solution.
How many parameters does the throw expression can have?
Select an option to see the answer and solution.
Which of the following syntax is used to convert any variable to its original type?
A. any_cast<variable_name>();
B. any_cast(variable_name);
C. <original_type>(variable_name);
D. any_cast<original_type>(variable_name);
Select an option to see the answer and solution.
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;
fl1.assign(5,10);
for (int&c : fl1)
cout << c << " ";
cout<<endl;
fl1.insert_after(fl1.begin(), {1,2,3});
for (int&c : fl1)
cout << c << " ";
cout<<endl;
return 0;
}A. 10 10 10 10 10
10 1 2 3 10 10 10 10
B. 10 2 3 10 10 10 10
10 10 10 10 10
C. Error
D. Segmentation fault
Select an option to see the answer and solution.
How the list containers are implemented?
A. Using Double linked list
B. Using Single linked list
C. Using Single & Double linked list
D. Using linear linked list
Select an option to see the answer and solution.
How to protect the heap from affecting the memory?
A. Avoid using pointers for associating two data structures
B. Embed pointed child objects into the parent object
C. Allocate objects in chunks
D. All of the mentioned
Select an option to see the answer and solution.