Q121
Open questionSelect an option to see the answer and solution.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
1,008
Questions
7/51
Page
Pick an option on a question to see the right answer and solution.
Q121
Open questionSelect an option to see the answer and solution.
Q122
Open question#include <iostream>
#include <exception>
using namespace std;
int main ()
{
try
{
int* myarray = new int[1000];
cout << "allocated";
}
catch (exception& e)
{
cout << "Standard exception: " << e.what() << endl;
}
return 0;
}Select an option to see the answer and solution.
Q123
Open questionSelect an option to see the answer and solution.
Q124
Open question#include <iostream>
#include <string>
using namespace std;
int main()
{
cout<<is_same<int,char>::value;
cout<<is_same<char[10], char[10]>::value;
cout<<is_same<char*[10], string>::value;
return 0;
}Select an option to see the answer and solution.
Q125
Open question#include <iostream>
#include <queue>
using namespace std;
int main ()
{
queue<int> myqueue;
myqueue.push(12);
myqueue.push(75);
myqueue.back() -= myqueue.front();
cout << myqueue.back() << endl;
return 0;
}Select an option to see the answer and solution.
Q126
Open question#include <iostream>
#include <functional>
#include <numeric>
using namespace std;
int myfunction (int x, int y)
{
return x + 2 * y;
}
struct myclass
{
int operator()(int x, int y)
{
return x + 3 * y;
}
} myobject;
int main ()
{
int init = 100;
int numbers[] = {10, 20, 30};
cout << accumulate (numbers, numbers + 3, init, minus<int>() );
cout << endl;
return 0;
}Select an option to see the answer and solution.
Q127
Open questionSelect an option to see the answer and solution.
Q128
Open question#include <iostream>
#include <string>
using namespace std;
int main()
{
cout<<rank<remove_extent<string[10][20]>::type>::value;
cout<<rank<remove_extent<string[10][20][30]>::type>::value;
return 0;
}Select an option to see the answer and solution.
Q129
Open question#include <stdio.h>
#include <ctype.h>
int main ()
{
int i = 0;
char str[] = "C";
while (str[i])
{
if (isalpha(str[i]))
printf ("alphabetic");
else
printf ("not alphabetic");
i++;
}
return 0;
}Select an option to see the answer and solution.
Q130
Open questionSelect an option to see the answer and solution.
Q131
Open questionSelect an option to see the answer and solution.
Q132
Open question#include <iostream>
using namespace std;
int main()
{
int var = -12;
try {
cout<<"Inside try\n";
if (var < 0)
{
throw var;
cout<<"After throw\n";
}
}
catch (char var ) {
cout<<"Exception Caught\n";
}
cout<<"After catch\n";
return 0;
}Select an option to see the answer and solution.
Q133
Open questionSelect an option to see the answer and solution.
Q134
Open questionSelect an option to see the answer and solution.
Q135
Open question#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
int main()
{
srand((unsigned)time(0));
int ran;
for (int i = 0; i < 2; i++)
{
ran = (rand() % 10) + 1;
cout << ran;
}
}Select an option to see the answer and solution.
Q136
Open questionSelect an option to see the answer and solution.
Q137
Open questionSelect an option to see the answer and solution.
Q138
Open question#include <iostream>
#include <functional>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main ()
{
vector <string*> numbers;
numbers.push_back ( new string ("one") );
numbers.push_back ( new string ("two") );
numbers.push_back ( new string ("three") );
vector <int> lengths ( numbers.size() );
transform (numbers.begin(), numbers.end(), lengths.begin(),
mem_fun(&string :: length));
for (int i = 0; i < 3; i++)
{
cout << lengths[i];
}
return 0;
}Select an option to see the answer and solution.
Q139
Open questionSelect an option to see the answer and solution.
Q140
Open questionSelect an option to see the answer and solution.