Vidyalelo
C++ Programming · all questions

C++ miscellaneous
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

1,008

Questions

28/51

Page

Pick an option on a question to see the right answer and solution.

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main()
{
    char name[30];
    cout << "Enter name: ";
    gets(name);
    cout << "Name: ";
    puts(name);
    return 0;
}

Select an option to see the answer and solution.

Which keyword can be used in template?

Select an option to see the answer and solution.

Which are done by compiler for templates?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include <iostream> 
#include <vector> 
 
using namespace std; 
 
int main() 
{ 
    vector<int> v1;
    vector<int> v2; 
    for (int i = 1; i <= 5; i++) 
        v1.push_back(i);
    for (int i = 6; i <= 10; i++) 
        v2.push_back(i);
    v1.swap(v2);
    for(int i=0;i<v1.size();i++)
    	cout<<v1[i]<<" ";
    for(int i=0;i<v2.size();i++)
    	cout<<v2[i]<<" ";
    cout<<endl;
    return 0; 
}

Select an option to see the answer and solution.

How many types of linkages are there in C++?

Select an option to see the answer and solution.

Which of the following is correct about the shift?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include <vector> 
#include <algorithm> 
#include <iostream> 
 
using namespace std;
 
int main() 
{ 
    vector<int> v; 
    for(int i=0;i<10;i++)
 	v.push_back(i+1);
    for(int i=0;i<10;i++)
	cout<<v[i]<<" ";
    cout<<endl;
    random_shuffle(v.begin(), v.end());
    for(int i=0;i<10;i++)
	cout<<v[i]<<" ";
    return 0;
}

Select an option to see the answer and solution.

What is any in C++?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include<iostream>
#include "math.h"
using namespace std;
double MySqrt(double d)
{
    if (d < 0.0)
    throw "Cannot take sqrt of negative number";     
    return sqrt(d);
}
int main()
{
    double d = 5;
    cout << MySqrt(d) << endl;
}

Select an option to see the answer and solution.

Choose the correct formatted code.

Options are not available for this question.

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <tuple>
using namespace std;
int main()
{
	tuple <int, char, string> tp1;
	tp1 = make_tuple(6, 'a', "Hello");
	int x;
	char y;
	string z;
	tie(x,y,z) = tp1;
	cout<<"x: "<<x<<"\ny: "<<y<<"\nz: "<<z<<endl;
	return 0;
}

Select an option to see the answer and solution.

Which of the following operators are overloaded for functors?

Select an option to see the answer and solution.

What is mersenne_twister_engine?

Select an option to see the answer and solution.

Which operator is used to declare the destructor?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include <iostream>
#include <string>
#include <tuple>
using namespace std;
int main()
{
	tuple <int, char, string> tp;
	tp = make_tuple(4, '1', "Hello");
	return 0;
}

Select an option to see the answer and solution.

Which operator is used to access the first or second element of a pair?

Select an option to see the answer and solution.

How the relationship is made in Association?

Select an option to see the answer and solution.

Which value is placed in the base class?

Select an option to see the answer and solution.

How many parameters are required for sort_heap function?

Select an option to see the answer and solution.

What are the Generators in C++?

Select an option to see the answer and solution.