Online Test

:

 

What is the output of this program?

  #include <iostream.h>
    using namespace std;
    int main ()
    {
        int a = 100;
        double b = 3.14;
        cout << a;
        cout << endl;
        cout << b << endl << a * b;
        endl (cout);
        return 0;
    }

What will be the output of the following program?

#include <iostream.h>
    #include <cstring.h>
    using namespace std;
    int main ()
    {
        char str1[10] = "Hello";
        char str2[10] = "World";
        char str3[10];
        int  len ;
        strcpy( str3, str1);
        strcat( str1, str2)
        len = strlen(str1);
        cout << len << endl;
        return 0;
    }

What is the output of this program?

  #include <iostream.h>
    #include <algorithm.h>
    using namespace std;
    bool myfn(int i, int j) 
    {
        return i < j;
    }
    int main () 
    {
        int myints[ ] = {3, 7, 2, 5, 6, 4, 9};
        cout <<  *min_element(myints, myints + 7, myfn) << '\n';
        cout << *max_element(myints, myints + 7, myfn) << '\n';
        return 0;
    }

Which of the following statement is correct about the program given below?

#include<iostream.h>
long GetNumber(long int Number)
{
    return --Number;
}
float GetNumber(int Number)
{
    return ++Number;
}
int main()
{
    int x = 20;
    int y = 30;
    cout<< GetNumber(x) << " ";
    cout<< GetNumber(y) ;
    return 0; 
}

What is the output of this program?

 #include <iostream.h>
    #include <algorithm.h>
    #include <vector.h>
    using namespace std;
    int main () 
    {
        vector<int> myvector;
        for (int i = 1; i < 6; ++i) 
            myvector.push_back(i);
        reverse(myvector.begin(), myvector.end());
        for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
            cout << ' ' << *it;
        return 0;
    }

What is the output of this program?

#include <iostream.h>
    using namespace std;
    class Foo
    {
        public:
        Foo(int i = 0){ _i = i;}
        void f()
        {
            cout << "Executed"<<endl;
        }
        private:
        int _i;
    };
    int main()
    {
        Foo *p = 0;
        p -> f();
    }

What is the output of this program?

 #include <stdio.h>
    int main ()
    {
        FILE * p;
        long size;
        p = fopen ("test.txt", "rb");
        if (p == NULL) 
            perror ("Error opening file");
        else
        {
            fseek (p, 0, SEEK_END); 
            size = ftell (p);
            fclose (p);
            printf (" %ld\n", size);
        }
        return 0;
    }

What is the output of this program?

 #include <iostream.h>
   #include <string.h>
   using namespace std;
   int main ()
   {
       string str ("Ubuntu");
       cout << str.capacity();
       cout << str.max_size();
       return 0;
   }

Which parameter is legal for non-type template?


What is the output of this program?

#include <iostream.h>
    using namespace std;
    template 
    type Max(type Var1, type Var2)
    {
        return Var1 > Var2 ? Var1:Var2;
    }
    int main()
    {
        int p;
        p = Max(100, 200);
        cout << p << endl;
        return 0;
    }

Pick out the correct statement about sequence point.


What is the output of this program?

   #include <iostream.h>
    using namespace std;
    int main()
    {
        unsigned long x = 64;
        cout << x << oct << x << endl;
        return 0;
    }

What is the output of this program?

   #include <iostream.h>
    #include <typeinfo.h>
    using namespace std;
    class A 
    { 
    };
    int main()
    { 
        char c; float x;
        if (typeid(c) != typeid(x))
        cout << typeid(c).name() << endl;
        cout << typeid(A).name();
        return 0;
    }

 


What is the output of this program?

#include <iostream.h>
    #include <algorithm.h>
    #include <vector.h>
    using namespace std;
    int main () 
    {
        int myints[] = {1, 2, 3, 4 ,5};
        vector<int> v(myints, myints + 5);
        v.push_back(33); 
        push_heap (v.begin(),v.end());
        cout << v.front() << '\n';
        sort_heap (v.begin(),v.end());
        return 0;
    }

What is the output of this program?

#include <iostream.h>
    #include <exception>
    using namespace std;
    class base { virtual void dummy() {} };
    class derived: public base { int a; };
    int main () 
    {
        try 
        {
            base * pba = new derived;
            base * pbb = new base;
            derived * pd;
            pd = dynamic_cast<derived*>(pba);
            if (pd == 0) 
                cout << "Null pointer on first type-cast" << endl;
            pd = dynamic_cast<derived*>(pbb);
            if (pd == 0) 
                cout << "Null pointer on second type-cast" << endl;
        } 
        catch (exception& e) 
        {
            cout << "Exception: " << e.what();
        }
        return 0;
    }

What is the output of this program?

    #include <iostream.h>
    #include <vector.h>
    #include <algorithm.h>
    using namespace std;
    void show(const vector<int>& vi)
    {
        for (size_t i = 0; i < vi.size(); ++i)
            cout << vi[i];
        cout << endl;
    }
    int main()
    {
        vector<int> vi;
        vi.push_back(3);
        vi.push_back(5);
        vi.push_back(5);
        sort(vi.begin(), vi.end());
        show(vi);
        while(next_permutation(vi.begin(), vi.end()))
            show(vi);
        return 0;
    }

Which of the following statement is correct about the program given below?

#include
int EpiTest(int x, int y);
int EpiTest(int x, int y, int z = 5);
int main()
{
    cout<< EpixTest(2, 4) << endl; 
    return 0;
}
int EpiTest(int x, int y)
{
    return x * y;
}
int EpiTest(int x, int y, int z = 5)
{
    return x * y * z; 
}

What is the output of this program?

  #include <iostream.h>
    #include <algorithm.h>
    #include <vector.h>
    using namespace std;
    bool myfunction (int i,int j) { return (i<j); }
    int main () 
    {
        int myints[] = {9, 8, 7, 6, 5};
        vector<int> myvector (myints, myints + 5);
        partial_sort (myvector.begin(), myvector.begin() + 3, myvector.end());
        partial_sort (myvector.begin(), myvector.begin() + 2, myvector.end(), 
        myfunction);
        for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
            cout << ' ' << *it;
        return 0;
    }

What is the use of RAII in c++ programing?


What is the output of this program?

  #include <iostream.h>
   #include <string.h>
   using namespace std;
   int main ()
   {
       string str ("nobody does like this");
       string key ("nobody");
       size_t f;
       f = str.rfind(key);
       if (f != string::npos)
           str.replace (f, key.length(), "everybody");
       cout << str << endl;
       return 0;
   }

 


What is the output of this program?

  #include <stdexcept.h>
    #include <limits.h>
    #include <iostream.h>
    using namespace std;
    void MyFunc(char c)
    {
        if (c < numeric_limits<char>::max())
            return invalid_argument;
    }
    int main()
    {
        try
        {
            MyFunc(256);
        }
        catch(invalid_argument& e)
        {
            cerr << e.what() << endl;
            return -1;
        }
        return 0;
    }

What is the kind of execution does sequence point allow?


What is the output of this program?

 #include <iostream.h>
    using namespace std;
    struct A 
    {
        virtual void f()  
        { 
            cout << "Class A" << endl; 
        }
    };
    struct B : A 
    {
        virtual void f() 
        { 
            cout << "Class B" << endl;
        }
    };
    struct C : A 
    {
        virtual void f() 
        {
            cout << "Class C" << endl; 
        }
    };
    void f(A* arg) 
    {
        B* bp = dynamic_cast<B*>(arg);
        C* cp = dynamic_cast<C*>(arg);
        if (bp)
            bp -> f();
        else if (cp)
            cp -> f();
        else
            arg -> f();  
    };
    int main() 
    {
        A aobj;
        C cobj;
        A* ap = &cobj;
        A* ap2 = &aobj;
        f(ap);
        f(ap2);
    }

What is the output of this program?

 #include <iostream.h>
    using namespace std;
    template 
    inline T square(T x)
    {
        T result;
        result = x * x;
        return result;
    };
    int main()
    {
        int i, ii;
        float x, xx;
        double y, yy;
        i = 2;
        x = 2.2;
        y = 2.2;
        ii = square(i);
        cout << i << ""  << ii << endl;
        yy = square(y);
        cout << y << "" << yy << endl;
    }

When our function doesn’t need to return anything means what we will as parameter in function?

 

About Us

TechEpi.com is an online learning website.We cover the latest tech news,online tutorials,blog,online test for Aptitude,C,Java,PHP to improve your knowledge.

Newsletter


Follow TechEpi on