81. What will be the output of the following C++ code?
#include <iostream>
#include <iterator>
using namespace std;
int main ()
{
try {
double value1, value2;
istream_iterator<double> eos;
istream_iterator<double> iit (cin);
if (iit != eos)
value1 = *iit;
iit++;
if (iit != eos)
value2 = *iit;
cout << (value1 * value2) << endl;
}
catch (...) {
cout << "Unknown exception: " << endl;
}
return 0;
}
#include <iostream>
#include <iterator>
using namespace std;
int main ()
{
try {
double value1, value2;
istream_iterator<double> eos;
istream_iterator<double> iit (cin);
if (iit != eos)
value1 = *iit;
iit++;
if (iit != eos)
value2 = *iit;
cout << (value1 * value2) << endl;
}
catch (...) {
cout << "Unknown exception: " << endl;
}
return 0;
}82. Which is called on allocating the memory for the array of objects?
83. What will be the type of output of vector cross product?
84. 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 <int>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 <int>a1;
cout<<a1.func(3,2)<<endl;
cout<<a1.func(3.0,2.0)<<endl;
return 0;
}85. Which keyword is used to declare the min and max functions?
86. What is the syntax of inheritance of class?
87. What will be the output of the following C++ code?
#include <stdio.h>
int main ()
{
FILE * p;
int c;
int n = 0;
p = fopen ("myfile.txt", "r");
if (p == NULL)
perror ("Error opening file");
else
{
do {
c = getc (p);
if (c == '$')
n++;
} while (c != EOF);
fclose (p);
printf ("%d\n", n);
}
return 0;
}
#include <stdio.h>
int main ()
{
FILE * p;
int c;
int n = 0;
p = fopen ("myfile.txt", "r");
if (p == NULL)
perror ("Error opening file");
else
{
do {
c = getc (p);
if (c == '$')
n++;
} while (c != EOF);
fclose (p);
printf ("%d\n", n);
}
return 0;
}88. Which function is used to check whether a character is printable on console?
89. 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); }
int main ()
{
int myints[] = {9, 8, 7, 6, 5};
vector<int> myvector (myints, myints + 5);
partial_sort (myvector.begin(), myvector.begin() + 3, myvector.end());
partial_sort (myvector.begin(), myvector.begin() + 2, myvector.end(),
myfunction);
for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
cout << ' ' << *it;
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool myfunction (int i,int j) { return (i<j); }
int main ()
{
int myints[] = {9, 8, 7, 6, 5};
vector<int> myvector (myints, myints + 5);
partial_sort (myvector.begin(), myvector.begin() + 3, myvector.end());
partial_sort (myvector.begin(), myvector.begin() + 2, myvector.end(),
myfunction);
for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
cout << ' ' << *it;
return 0;
}90. What may be the name of the parameter that the template should take?
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 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
