What is the output of the program?
#include
#include
using namespace std;
int main () {
string s1 = "Hello", s2 = "World";
s2 = s1 + s2;
cout << s2;
return 0;
}
A. It prints: Hello
B. It prints: HelloWorld
C. It prints: WorldHello
D. It prints: WorldHelloWorld
What happens when you attempt to compile and run the following code?
#include
using namespace std;
void fun(int);
int main()
{
int a=0;
fun(a);
return 0;
}
void fun(int n)
{
if(n < 2)
{
fun(++n);
cout << n;
}
}
A. It prints: 21
B. It prints: 012
C. It prints: 0
D. None of these
Which of the following can be checked in a switch?case statement?
A. char
B. int
C. enum
D. double
What is the output of the program given below?
#include
using namespace std;
int main (int argc, const char * argv[])
{
int i=10;
{
int i=0;
cout<
}
cout<
return 0;
}
A. 1010
B. 100
C. 010
D. None of these
What happens when you attempt to compile and run the following code?
#include
using namespace std;
#define FUN(arg) if(arg) cout<<"Test";
int main()
{
int i=1;
FUN(i<3);
return 0;
}
A. It prints: 0
B. It prints: T
C. It prints: T0
D. It prints: Test
What happens when you attempt to compile and run the following code?
#include
using namespace std;
namespace myNamespace1
{
int x = 5;
int y = 10;
}
namespace myNamespace2
{
float x = 3.14;
float y = 1.5;
}
int main () {
{
using namespace myNamespace1;
cout << x << " ";
}{
using namespace myNamespace2;
cout << y;
}
return 0;
}
A. It prints: 5 1.5
B. It prints: 3.14 10
C. Compilation error
D. None of these
What happens when you attempt to compile and run the following code?
#include
#include
using namespace std;
class complex{
double re;
double im;
public:
complex() : re(1),im(0.4) {}
bool operator==(complex andt);
};
bool complex::operator == (complex andt){
if((this?>re == t.re) andand (this?>im == t.im))
return true;
else
return false;
}
int main(){
complex c1,c2;
if (c1==c2)
cout << "OK";
else {
cout << "ERROR";
}
}
A. It prints: OK
B. It prints: ERROR
C. Compilation error
D. Runtime error.
What will be the output of the program?
#include
using namespace std;
int main()
{
int i=0;
for(; i<=5; i++)
cout << i;
return 0;
}
A. 012345
B. 0123
C. 5
D. 6
What happens when you attempt to compile and run the following code?

A. It causes a compilation error
B. It prints: Tesc failed
C. .It prints: failed
D. It prints: Tesc
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class BaseC
{
public:
int *ptr;
BaseC() { ptr = new int(10);}
BaseC(int i) { ptr = new int(i); }
~BaseC() { delete ptr; }
};
void fun(BaseC x);
int main()
{
BaseC *o = new BaseC(5);
fun(*o);
}
void fun(BaseC x) { cout << "Hello:"<<*x.ptr; }
A. It prints: Hello:50
B. It prints: Hello:10
C. It prints: Hello:5
D. Compilation error