C-Plus-Plus Questions

0 votes, 0 avg
215

C-Plus-Plus Questions

1 / 15

1. Find the output of below program:-

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

do
{
    if(i % 5 == 0)
    {
       cout<

2 / 15

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

        #include 

        using namespace std;

        int main ()

        {

            int n;

            n = -77;

            cout.width(4); 

            cout << internal << n << endl;

            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. 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;  
}  

5 / 15

5. What is dangling pointer?

6 / 15

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

        #include 

        using namespace std;

        void Sum(int a, int b, int & c)

        {

            a = b + c;

            b = a + c;

            c = a + b;

        }

        int main()

        {

            int x = 2, y =3;

            Sum(x, y, y);

            cout << x << " " << y;

            return 0; 

        }

                            

7 / 15

7. Pick the incorrect statement about Character-Array.

8 / 15

8. Consider the following given program and choose the most appropriate output from the given options:

#include   
using namespace std;   
class Base {   
public:   
    Base()     
    { cout<<"Constructing Base n"; }   
    ~Base()   
    { cout<<"Destructing Base n"; }     
};   
class Derived: public Base {   
public:   
    Derived()      
    { cout<<"Constructing Derived n"; }   
    ~Derived()   
    { cout<<"Destructing Derived n"; }   
};   
   
int main(void)   
{   
    Derived *d = new Derived();   
    Base *b = d;   
    delete b;   
    return 0;   
}  

9 / 15

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

10 / 15

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

11 / 15

11. Which is the correct statement about operator overloading?

12 / 15

12. 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<

13 / 15

13. Which concept allows you to reuse the written code in C++?

14 / 15

14. Which of the following can be used to create an abstract class in the C++ programming language?

15 / 15

15. How many times hello is printed?

int main()
{
    int i=0;
    lbl:
    cout<<"CppBuzz.com";
    i++;
    if(i<5)
    {
	goto lbl;
    }
return 0;

}

Your score is

The average score is 32%

0%