71. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
#include <cstdlib>
#include <exception>
void Funct()
{
cout << "Funct() was called by terminate()." << endl;
exit(0);
}
int main()
{
try
{
set_terminate(Funct);
throw "Out of memory!";
}
catch(int)
{
cout << "Integer exception raised." << endl;
}
return 0;
}
#include <iostream>
using namespace std;
#include <cstdlib>
#include <exception>
void Funct()
{
cout << "Funct() was called by terminate()." << endl;
exit(0);
}
int main()
{
try
{
set_terminate(Funct);
throw "Out of memory!";
}
catch(int)
{
cout << "Integer exception raised." << endl;
}
return 0;
}72. What can be used to input a string with blank space?
73. Which is dependant on template parameter?
74. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main()
{
double Op1 = 10, Op2 = 5, Res;
char Op;
try
{
if (Op != '+' && Op != '-' && Op != '*' && Op != '/')
throw Op;
switch(Op)
{
case '+':
Res = Op1 + Op2;
break;
case '-':
Res = Op1 - Op2;
break;
case '*':
Res = Op1 * Op2;
break;
case '/':
Res = Op1 / Op2;
break;
}
cout << "\n" << Op1 << " " << Op << " "<< Op2 << " = " << Res;
}
catch (const char n)
{
cout << n << " is not a valid operator";
}
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
double Op1 = 10, Op2 = 5, Res;
char Op;
try
{
if (Op != '+' && Op != '-' && Op != '*' && Op != '/')
throw Op;
switch(Op)
{
case '+':
Res = Op1 + Op2;
break;
case '-':
Res = Op1 - Op2;
break;
case '*':
Res = Op1 * Op2;
break;
case '/':
Res = Op1 / Op2;
break;
}
cout << "\n" << Op1 << " " << Op << " "<< Op2 << " = " << Res;
}
catch (const char n)
{
cout << n << " is not a valid operator";
}
return 0;
}75. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout<<rank<remove_all_extents<string[10][20]>::type>::value;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout<<rank<remove_all_extents<string[10][20]>::type>::value;
return 0;
}76. Which classes are called as mixin?
77. Which is used to handle the exceptions in c++?
78. What will be the output of the following C++ code?
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main ()
{
char str[] = "ffff";
long int number;
if (isxdigit(str[0]))
{
number = strtol (str, NULL, 16);
printf ("%ld\n", number);
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main ()
{
char str[] = "ffff";
long int number;
if (isxdigit(str[0]))
{
number = strtol (str, NULL, 16);
printf ("%ld\n", number);
}
return 0;
}79. Which header file is used for reading and writing to a file?
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:
A(){
cout<<"Created\n";
}
~A(){
cout<<"Destroyed\n";
}
};
int main(int argc, char const *argv[])
{
A a;
return 0;
}
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
template<class T>
class A
{
public:
A(){
cout<<"Created\n";
}
~A(){
cout<<"Destroyed\n";
}
};
int main(int argc, char const *argv[])
{
A a;
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 4
- 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
