21.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
template <class T>
inline T square(T x)
{
    T result;
    result = x * x;
    return result;
};
template <>
string square<string>(string ss)
{
    return (ss+ss);
};
int main()     
{
    int i = 4, ii;
    string ww("A");
    ii = square<int>(i);
    cout << i << ii;
    cout << square<string>(ww) << endl;
}

22.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int array[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
void swap(int x, int y)
{
    int temp = array[x];
    array[x] = array[y];
    array[y] = temp;
    return;
}
void printArray(int size)
{
    int i;
    for (i = 0; i < size; i++)
        cout << array[i] << " ";
    cout << endl;
    return;
}
void permute(int k, int size)
{
    int i;
    if (k == 0)
        printArray(size);
    else
    {
        for (i = k - 1;i >= 0;i--)
        {
            swap(i, k - 1);
            permute(k - 1, size);
            swap(i, k - 1);
        }
    }
    return;
}
int main()
{
    permute(3, 3);
    return 0;
}

23.
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
	int a;
    public:
	virtual void func() = 0;
};
 
class B: public A
{
    public:
	void func(){
		cout<<"Class B"<<endl;
	}	
};
 
int main(int argc, char const *argv[])
{
	A *a;
	a->func();
	return 0;
}

24.
Which of the following is correct about any() function in bitset?

25.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class MyInterface 
{
    public:
    virtual void Display() = 0;
};
class Class1 : public MyInterface 
{
    public:
    void Display() 
    {
        int  a = 5;
        cout << a;
    }
};
class Class2 : public MyInterface 
{
    public:
    void Display()
    {
        cout <<" 5" << endl;
    }
};
int main()
{
    Class1 obj1;
    obj1.Display();
    Class2 obj2;
    obj2.Display();
    return 0;
}

28.
What does this template function indicates?
==================
template<class T>
void func(T a)
{
	cout<<a;
}
==================

29.
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);
}
struct myclass {
bool operator() (int i, int j)
{
    return (i < j);
} 
} myobject;
int main () 
{
    int myints[] = {10, 9, 8};
    vector<int> myvector (myints, myints + 3);
    sort (myvector.begin(), myvector.begin() + 2);
    sort (myvector.begin() + 1, myvector.end(), myfunction);
    sort (myvector.begin(), myvector.end(), myobject);
    for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
        cout << ' ' << *it;
    return 0;
}