Question 111

What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
void fun(int*);
int main()
{
int i=2;
fun(&i);
cout<<i;
return 0;
}
void fun(int *i)
{
*i = *i**i;
}
  • Question 112

    What is the output of the program given below?
    #include <iostream>
    using namespace std;
    int main (int argc, const char * argv[])
    {
    float f=?10.501;
    cout<<(int)f;
    }
  • Question 113

    What happens when you attempt to compile and run the following code?
    #include <iostream>
    using namespace std;
    int main()
    {
    float x=3.5,y=1.6;
    int i,j=2;
    i = x + j + y;
    cout << i;
    return 0;
    }
  • Question 114

    What happens when you attempt to compile and run the following code?
    #include <iostream>
    #include <string>
    using namespace std;
    class complex{
    double re;
    double im;
    public:
    complex() : re(1),im(0.4) {}
    bool operator==(complex &t);
    };
    bool complex::operator == (complex &t){
    if((this?>re == t.re) && (this?>im == t.im))
    return true;
    else
    return false;
    }
    int main(){
    complex c1,c2;
    if (c1==c2)
    cout << "OK";
    else {
    cout << "ERROR";
    }
    }
  • Question 115

    What happens when you attempt to compile and run the following code?
    #include <iostream>
    #include <string>
    using namespace std;
    struct Person {
    string name;
    int age;
    };
    class First
    {
    Person *person;
    public:
    First() {person = new Person;
    person?>name = "John";
    person?>age = 30;
    }
    void Print(){
    cout<<person?>name << " "<< person?>age;
    }
    };
    int main()
    {
    First t;
    t.Print();
    }