91. What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool IsOdd (int i)
{
return (i%2)==1;
}
int main ()
{
vector<int> v = {4,2,10,5,1,8};
for(int i=0;i<v.size();i++)
cout<<v[i]<<" ";
cout<<endl;
sort(v.begin(), v.end());
for(int i=0;i<v.size();i++)
cout<<v[i]<<" ";
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool IsOdd (int i)
{
return (i%2)==1;
}
int main ()
{
vector<int> v = {4,2,10,5,1,8};
for(int i=0;i<v.size();i++)
cout<<v[i]<<" ";
cout<<endl;
sort(v.begin(), v.end());
for(int i=0;i<v.size();i++)
cout<<v[i]<<" ";
return 0;
}
92. How many types of Association can be there between classes?
93. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
template<typename T>
inline T square(T x)
{
T result;
result = x * x;
return result;
};
int main()
{
int i, ii;
float x, xx;
double y, yy;
i = 2;
x = 2.2;
y = 2.2;
ii = square(i);
cout << i << " " << ii << endl;
yy = square(y);
cout << y << " " << yy << endl;
}
#include <iostream>
using namespace std;
template<typename T>
inline T square(T x)
{
T result;
result = x * x;
return result;
};
int main()
{
int i, ii;
float x, xx;
double y, yy;
i = 2;
x = 2.2;
y = 2.2;
ii = square(i);
cout << i << " " << ii << endl;
yy = square(y);
cout << y << " " << yy << endl;
}
94. What type of access does deque and vector provide?
95. What are Iterators?
96. Indexing of bitset variables starts from . . . . . . . .
97. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class Base
{
protected:
int a;
public:
Base()
{
a = 34;
}
Base(int i)
{
a = i;
}
virtual ~Base()
{
if (a < 0) throw a;
}
virtual int getA()
{
if (a < 0)
{
throw a;
}
}
};
int main()
{
try
{
Base b(-25);
cout << endl << b.getA();
}
catch (int)
{
cout << endl << "Illegal initialization";
}
}
#include <iostream>
using namespace std;
class Base
{
protected:
int a;
public:
Base()
{
a = 34;
}
Base(int i)
{
a = i;
}
virtual ~Base()
{
if (a < 0) throw a;
}
virtual int getA()
{
if (a < 0)
{
throw a;
}
}
};
int main()
{
try
{
Base b(-25);
cout << endl << b.getA();
}
catch (int)
{
cout << endl << "Illegal initialization";
}
}
98. By using which function does the buffer are automatically flushed?
99. Which function is used to access the last element of an array class?
100. How many constructors can present in a class?
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