C++ Institute Related Exams
CPA Exam

Which code, inserted at line 10, generates the output "Hello World"?
#include
#include
using namespace std;
string fun(string, string);
int main()
{
string s="Hello";
string *ps;
ps = &s;
//insert code here
return 0;
}
string fun(string s1, string s2)
{
return s1+s2;
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
class BaseClass
{
public:
int *ptr;
BaseClass(int i) { ptr = new int(i); }
~BaseClass() { delete ptr; delete ptr;}
void Print() { cout << *ptr; }
};
void fun(BaseClass x);
int main()
{
BaseClass o(10);
fun(o);
o.Print();
}
void fun(BaseClass x) {
cout << "Hello:";
}
What happens when you attempt to compile and run the following code?
#include
using namespace std;
int main()
{
int i=2;
switch(i)
{
case 1:
cout<<"Hello";
case 2:
cout<<"world";
case 3:
cout<<"End";
} return 0;
}