C-Plus-Plus Questions

0 votes, 0 avg
217

C-Plus-Plus Questions

1 / 15

1. What is Pseudo-random number engines?

2 / 15

2. What will be the output of the following C++ code?

#include
using namespace std;
 
class Test
{
  protected:
    int x;
  public:
    Test (int i):x(i) { }
    void fun() const  { cout << "fun() const " << endl; }
    void fun()        {  cout << "fun() " << endl;     }
};
 
int main()
{
    Test t1 (10);
    const Test t2 (20);
    t1.fun();
    t2.fun();
    return 0;
}

3 / 15

3. Observer the given C++ program carefully and choose the correct output from the given options:

#include   
#include   
using namespace std;  
int main()  
{  
    cout<::value; // case A  
    cout<::value; // case B  
    cout<::value;  // case c  
    return 0;  
}  

4 / 15

4. Which of the following C++ code will give error on compilation?

================code 1=================
#include 
using namespace std;
int main(int argc, char const *argv[])
{
	cout<<"Hello World";
	return 0;
}
========================================
================code 2=================
#include 
int main(int argc, char const *argv[])
{
	std::cout<<"Hello World";
	return 0;
}
========================================

5 / 15

5. What will be the output of the following C++ code?

#include 
#include 
using namespace std;
int main()
{
	cout<::type>::value;
	cout<::type>::value;
	return 0;
}

6 / 15

6. What is do-while loop also known as?

7 / 15

7. How structures and classes in C++ differ?

8 / 15

8. Would destructor be called, if yes, then due to which vector?

#include 
#include 
using namespace std;
 
class a
{
public :
    ~a()
    {
        cout << "destroy";
    }
};
int main()
{
   vector  *v1  = new vector;
   vector  *v2  = new vector;
   return 0;
}