C-Plus-Plus Questions

0 votes, 0 avg
1

C-Plus-Plus Questions

1 / 15

1. Among the following, which statement is correct about the Modularity?

2 / 15

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

3 / 15

3. A member function can always access the data in __________ , (in C++).

4 / 15

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

#include 
using namespace std;
void square (int *x, int *y)
{
	*x = (*x) * --(*y);
}
int main ( )
{
	int number = 30;
	square(&number, &number);
	cout << number;
	return 0;
}

5 / 15

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

#include 
using namespace std; 
template 
int arrMin(T arr[], int n)
{
   int m = max;
   for (int i = 0; i < n; i++)
      if (arr[i] < m)
         m = arr[i];
 
   return m;
}
 
int main()
{
   int arr1[]  = {10, 20, 15, 12};
   int n1 = sizeof(arr1)/sizeof(arr1[0]);
 
   char arr2[] = {1, 2, 3};
   int n2 = sizeof(arr2)/sizeof(arr2[0]);
 
   cout << arrMin(arr1, n1) << endl;
   cout << arrMin(arr2, n2);
   return 0;
}

6 / 15

6. Pick the incorrect statement about Character-Array.

7 / 15

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

        #include 

        using namespace std;

        double & WeeklyHours()

        {

            double h = 46.50;

            double &hours = h;

            return hours;

        }

        int main()

        {

            double hours = WeeklyHours();

            cout << "Weekly Hours: " << hours;

            return 0;

        }

8 / 15

8.

What is an object in c++?

9 / 15

9. Find the output of the following program.

main(){
  Float a = 5;
  switch(a){
     Case 5: cout <<”Interviewbit”;
     Default: cout <<”Scaler”;
  }
}

10 / 15

10. The correct statement for a function that takes pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to a integer is ____________

11 / 15

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