Question 111
Which of the following is a correct way to define the function fun() in the program below?
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
int a[2][2];
fun(a);
return 0;
}
Question 112
What will the variable "y" be in class B?
class A {
int x;
protected:
int y;
public:
int age;
};
class B: private A {
string name;
public:
void Print() {
cout << name << age;
}
};
Question 113
Which of the following is a user defined data type?
1: struct person { char name[20]; int age; };
2: int l=2;
3:
enum color {red,blue, green};
D.char c;
Question 114
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
struct {
int x;
char c;
union {
float f;
int i;
};
} s;
int main (int argc, const char * argv[])
{
s.x=10;
s.i=0;
cout << s.i << " " << s.x;
}
Question 115
What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
class Test {
float i,j;
};
class Add {
public:
int x,y;
Add (int a=3, int b=3) { x=a; y=b; }
int result() { return x+y;}
};
int main () {
Test test;
Add * padd;
padd = &test;
cout << padd?>result();
return 0;
}
