What is the expected output of the following program?
Answer : B
What is the output of the program?
#include
using namespace std;
#define PRINT(i) cout<
int main()
{
int y=2, z=3;
PRINT(y);
PRINT(z);
return 0;
}
Answer : B
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
int i=5;
switch(i)
{
case 1:
cout<<"Hello";
break;
case 2:
cout<<"world";
break;
case 3:
break;
default:
cout<<"End";
}
return 0;
}
Answer : C
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
int *a= new int;
*a=100;
cout << *a;
delete a;
}
Answer : B
Which of the following operations is INCORRECT?
Answer : C
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
class A {
protected:
int y;
public:
int x,z;
A() : x(2), y(2), z(1) { z = x + y; }
A(int a, int b) : x(a), y(b) { z = x + y;}
void Print() { cout << z; }
};
class B : public A {
public:
int y;
B() : A() {}
B(int a, int b) : A(a,b) {}
void Print() { cout << z; }
};
int main () {
A b;
b.Print();
return 0;
}
Answer : A
What is the output of the program if character 3 is supplied as input?
#include
using namespace std;
int main () {
int c;
cin >> c;
try
{
switch (c)
{
case 1:
throw 20;
case 2:
throw 5.2f;
case 3:
throw 'a';
}
}
catch (int e)
{ cout << "int exception. Exception Nr. " << e; }
catch (float e)
{ cout << "float exception. Exception Nr. " << e; }
catch (...)
{ cout << "An exception occurred."; }
return 0;
}
Answer : C