Question 76

What happens if you try to compile and run this program?
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
print("Test");
return 0;
}
void print(int c[])
{
cout<<c;
}
  • Question 77

    What happens when you attempt to compile and run the following code?
    #include <iostream>
    #include <string>
    using namespace std;
    class complex{
    double re, im;
    public:
    complex() : re(1),im(0.3) {}
    complex(double n) { re=n,im=n;};
    complex(int m,int n) { re=m,im=n;}
    complex operator+(complex &t);
    void Print() { cout << re << " " << im; }
    };
    complex complex::operator+ (complex &t){
    complex temp;
    temp.re = this->re + t.re;
    temp.im = this->im + t.im;
    return temp;
    }
    int main(){
    complex c1(1),c2(2),c3;
    c3 = c1 + c2;
    c3.Print();
    }
  • Question 78

    What happens when you attempt to compile and run the following code?
    #include <iostream>
    using namespace std;
    int f(int a, int b);
    int main()
    {
    float b;
    b = f(20,10);
    cout << b;
    return 0;
    }
    int f(int a, int b)
    {
    return a/b;
    }
  • Question 79

    What happens when you attempt to compile and run the following code?
    #include <iostream>
    #include <string>
    using namespace std;
    class A {
    protected:
    int y;
    public:
    int x;
    int z;
    A() { x=1; y=2; z=3; }
    A(int a, int b) : x(a), y(b) { z = x * y;}
    void Print() {
    cout << z;
    }
    };
    int main () {
    A a(2,5);
    a.Print();
    return 0; }
  • Question 80

    What happens when you attempt to compile and run the following code?
    #include <iostream>
    using namespace std;
    class Base {
    static int age;
    public:
    Base () {};
    ~Base () {};
    void setAge(int a=20) {age = a;}
    void Print() { cout << age;}
    };
    int Base::age=0;
    int main () {
    Base a;
    a.setAge(10);
    a.Print();
    a.setAge();
    a.Print();
    return 0;
    }