ExamVeda
Login
Home
41
Which header file is used for generating random numbers?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
42
What will be the output of the following C++ code?
#include<iostream>
using namespace std;
class X 
{
    int m;
    public:
    X() : m(10)
    {                                                       
    }
    X(int mm): m(mm)
    {
    }
    int getm()
    {
        return m;
    }
};
class Y : public X 
{
    int n;
    public:
    Y(int nn) : n(nn) {}                                                
    int getn() { return n; }
};
int main()
{
    Y yobj( 100 );
    cout << yobj.getm() << " " << yobj.getn() << endl;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
43
What will be the output of the following C++ code?
#include <iostream>
#include <bitset>
using namespace std;
int main()
{
	bitset<8> b1(95);
	bitset<8> b2(45);
	cout<<~b1<<endl;
	cout<<(b1|b2)<<endl;
	cout<<(b1&b2)<<endl;
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
44
Which function is used to check whether a character is a number?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
45
How many kinds of parameters are there in C++?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
46
What will be the output of the following C++ code?
#include <iostream>
#include <functional>
#include <numeric>
using namespace std;
int myfunction (int x, int y) 
{
    return x + 2 * y;
}
struct myclass 
{
    int operator()(int x, int y) 
    {
        return x + 3 * y;
    }
} myobject;
int main () 
{
    int init = 100;
    int numbers[] = {10, 20, 30};
    cout << accumulate(numbers, numbers + 3, init);
    cout << endl;
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
47
Which is used to get the input during runtime?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
48
What is meant by pure virtual function?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
49
What will be the output of the following C++ code?
#include <iostream>
#include <complex>
using namespace std;
int main()
{
	complex <double> cn(3.0, 5.0);
	cout<<"Complex number is: "<<real(cn)<<" + "<<imag(cn)<<"i"<<endl;
	return 0;
}
Discuss
Answer & Solution
Answer: Option A
Solution:
In the given C++ code, the complex class from the C++ Standard Library is used to represent a complex number.

In the statement complex cn(3.0, 5.0), the constructor initializes the real part as 3.0 and the imaginary part as 5.0.

The function real(cn) returns the real part of the complex number, which is 3.

The function imag(cn) returns the imaginary part, which is 5.

Hence, the output will be: Complex number is: 3 + 5i.
50
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
class poly
{
    protected:
    int width, height;
    public:
    void set_values(int a, int b)
    {
        width = a; height = b;
    }
};
class Coutput
{
    public:
    void output(int i);
};
void Coutput::output(int i)
{
    cout << i;
}
class rect:public poly, public Coutput
{
    public:
    int area()
    {
        return(width * height);
    }
};
class tri:public poly, public Coutput
{
    public:
    int area()
    {
        return(width * height / 2);
    }
};
int main()
{
    rect rect;
    tri trgl;
    rect.set_values(3, 4);
    trgl.set_values(4, 5);
    rect.output(rect.area());
    trgl.output(trgl.area());
    return 0;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board