ExamVeda
Login
Home
11
Which of the following function is used to get the actual number of elements stored in vector?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
12
What are functors in C++?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
13
How many streams are automatically created when executing a program?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
14
What will be the output of the following C++ code?
#include <iostream>
#include <vector>
using namespace std;
int main ()
{
    vector<int> myvector (3);
    for (unsigned i = 0; i < myvector.size(); i++)
    myvector.at(i) = i;
    for (unsigned i = 0; i < myvector.size(); i++)
    cout << ' ' << myvector.at(i);
    return 0;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
15
What is the use of is_array() function in C++?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
16
What will be the output of the following C++ code?
#include <iostream>
#include <new>
using namespace std;
int main ()
{
    int i, n;
    int * p;
    i = 2;
    p= new (nothrow) int[i];
    if (p == 0)
        cout << "Error: memory could not be allocated";
    else
    {
        for (n=0; n<i; n++)
        {
            p[n] = 5;
        }
        for (n = 0; n < i; n++)
            cout << p[n];
        delete[] p;
     }
     return 0;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
17
What is the correct syntax of defining function template/template functions?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
18
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
long factorial (long a)
{
    if (a > 1)
        return (a * factorial (a + 1));
    else
        return (1);
}
int main ()
{
    long num = 3;
    cout << num << "! = " << factorial ( num );
    return 0;
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
19
What will be the output of the following C++ code?
#include <vector> 
#include <algorithm>
#include <iostream>
#include <iterator>
using namespace std;
int square(int i) { return i * i; }
int main()
{
    vector<int> V, V2;
    V.push_back(0);
    V.push_back(1);
    V.push_back(2);
    transform(V.begin(), V.end(), back_inserter(V2), square);
    copy(V2.begin(), V2.end(), ostream_iterator<int>(cout, " "));
    cout << endl;
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
20
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class BaseClass 
{
    int x;
    public:
    void setx(int n) 
    {
        x = n;
    }
    void showx() 
    {
        cout << x ;
    }
};
class DerivedClass : private BaseClass
{
    int y;
    public:
    void setxy(int n, int m)
    {
        setx(n);      
        y = m;
    }
    void showxy() 
    {
        showx();       
        cout << y << '\n';
    }
};
int main()
{
    DerivedClass ob;
    ob.setxy(10, 20);
    ob.showxy();
    return 0;
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board