C-Plus-Plus Questions

0 votes, 0 avg
208

C-Plus-Plus Questions

1 / 15

1. what will be the output of the following C++ code snippet?

int main() 
{
int i=0,x=0;

for(i=1;i<10;i*=2)
{
    x++;
    cout<

2 / 15

2. Which of the following loops is best when we know the number of iterations?

3 / 15

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

#include 
    using namespace std;
    int operate (int a, int b)
    {
        return (a * b);
    }
    float operate (float a, float b)
    {
        return (a / b);
    }
    int main()
    {
        int x = 5, y = 2;
        float n = 5.0, m = 2.0;
        cout << operate(x, y) <<"t";
        cout << operate (n, m);
        return 0;
    }

4 / 15

4. What is C++?

5 / 15

5. What is the output of the given program?

#include < stdio.h >  
using namespace std;  
int main()  
{  
int array[] = {10, 20, 30};  
cout << -2[array];  
return 0;  
}  

6 / 15

6. what will be the output of the following C++ code snippet?

#include
void Execute(int &x, int y = 200)
{
 int TEMP = x + y;
 x+= TEMP;
 if(y!=200)
     cout<

7 / 15

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

        #include 

        using namespace std;

        void square (int *x)

        {

    	*x = (*x + 1) * (*x);

        }

        int main ( )

        {

    	int num = 10;

            square(&num);

            cout << num; 

            return 0;

        }

8 / 15

8. Which of the following is used for comments in C++?

9 / 15

9. what will be the output of the given program?

class base
{
public:
       base()
       {          
           cout<<"BCon";
       }
       ~base()
       {
	   cout<<"BDest ";
       }
};
class derived: public base
{
public:
       derived()
       {     cout<<"DCon ";
       }
       ~derived()
       {     cout<<"DDest ";
       }
};

int main()
{
derived object;
return 0; 
}

10 / 15

10. What is abstract class in C++?

11 / 15

11. What is Pseudo-random number engines?

12 / 15

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

#include 
    using namespace std;
    class Box
    {
        public :
        double length;
        double breadth;
        double height;
    };
    int main( )
    {
        Box Box1;
        double volume;
        Box1.height = 5;
        Box1.length = 6;
        Box1.breadth = 7.1;
        volume = Box1.height * Box1.length * Box1.breadth;
        cout << "Volume of Box1 : " << volume <

13 / 15

13. By which of the following can the if-else statement be replaced?

14 / 15

14. Exceptions are Caught at ?

15 / 15

15. Which option is false for the following code?

class A
{
 private : int sum(int x, int y)
 { 
  return x+y; 
 }
 public: A()
 {  
 }
 A(int x, int y)
 { 
  cout<

Your score is

The average score is 32%

0%