Question 101

What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int compare(int, int);
int main()
{
int x = compare(10, 20);
cout << x;
return 0;
}
int compare(int i, int j)
{
return i<j;
}
  • Question 102

    What is the output of the program given below?
    #include <iostream>
    using namespace std;
    int main (int argc, const char * argv[])
    {
    enum state { ok, error, warning};
    enum state s1, s2, s3, s4;
    s1 = ok;
    s2 = warning;
    s3 = error;
    s4 = ok;
    cout << s1<< s2<< s3<< s4;
    return 0;
    }
  • Question 103

    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;
    }
  • Question 104

    What is the output of the program?
    #include <iostream>
    #include <string>
    using namespace std;
    int main()
    {
    string s1="Wo";
    string s2;
    s2 = s1;
    string s3;
    s3 = s2.append("rldHello");
    cout << s3;
    return( 0 );
    }
  • Question 105

    What is the output of the program given below?
    #include <iostream>
    using namespace std;
    int main (int argc, const char * argv[])
    {
    int i=10;
    {
    int i=0;
    cout<<i;
    }
    {
    int i=5;
    cout << i;
    }
    cout<<i;
    return 0;
    }