71. To what kind of elements does non-modifying sequence algorithm can be applied?
72. What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int myints[] = { 10, 20, 30 ,40 };
int * p;
p = find (myints, myints + 4, 30);
--p;
cout << *p << '\n';
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
int myints[] = { 10, 20, 30 ,40 };
int * p;
p = find (myints, myints + 4, 30);
--p;
cout << *p << '\n';
return 0;
}73. Which container is used to store elements as key-value pair?
74. What is the use of has_value() function in any container?
75. Which of the following header files is required for creating and reading data files?
76. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
struct A
{
int i;
char j;
float f;
void func();
};
void A :: func() {}
struct B
{
public:
int i;
char j;
float f;
void func();
};
void B :: func() {}
int main()
{
A a; B b;
a.i = b.i = 1;
a.j = b.j = 'c';
a.f = b.f = 3.14159;
a.func();
b.func();
cout << "Allocated";
return 0;
}
#include <iostream>
using namespace std;
struct A
{
int i;
char j;
float f;
void func();
};
void A :: func() {}
struct B
{
public:
int i;
char j;
float f;
void func();
};
void B :: func() {}
int main()
{
A a; B b;
a.i = b.i = 1;
a.j = b.j = 'c';
a.f = b.f = 3.14159;
a.func();
b.func();
cout << "Allocated";
return 0;
}77. Which function allows you to set minimum width for the next input?
78. 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 = 2, ii;
string ww("A");
ii = square<int>(i);
cout << i << ": " << ii;
cout << square<string>(ww) << ":" << endl;
}
#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 = 2, ii;
string ww("A");
ii = square<int>(i);
cout << i << ": " << ii;
cout << square<string>(ww) << ":" << endl;
}79. How many categories of iterators are there in c++?
80. What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
template<class T>
class A
{
public:
T func(T a, T b){
return a/b;
}
};
int main(int argc, char const *argv[])
{
A <float>a1;
cout<<a1.func(3,2)<<endl;
cout<<a1.func(3.0,2.0)<<endl;
return 0;
}
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
template<class T>
class A
{
public:
T func(T a, T b){
return a/b;
}
};
int main(int argc, char const *argv[])
{
A <float>a1;
cout<<a1.func(3,2)<<endl;
cout<<a1.func(3.0,2.0)<<endl;
return 0;
}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 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
