21. How many sets of requirements are need in designing a container?
22. What will be the output of the following C++ code?
#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;
}
#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;
}
23. What kind of library is Standard Template Library?
24. What will be the output of the following C++ code?
#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;
}
#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;
}
25. What will be the output of the following C++ code?
#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;
}
#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;
}
26. What will be the output of the following C++ code?
#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;
}
#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;
}
27. What is the difference between begin() and cbegin() in vectors?
28. What will be the output of the following C++ code?
#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;
}
#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;
}
29. What will be the output of the following C++ code?
#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;
}
#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;
}
30. Which of the header file is used to implement algorithms provided by C++ STL?
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 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