C-Plus-Plus Questions

0 votes, 0 avg
191

C-Plus-Plus Questions

1 / 15

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

2 / 15

2. Find the output of the following program.

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

3 / 15

3. What did we call an array of the one-dimensional array?

4 / 15

4. How can one implement the run-time Polymorphism in the C++ programming language?

5 / 15

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