41. 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;
}
#include <iostream>
using namespace std;
int main()
{
char name[30];
cout << "Enter name: ";
gets(name);
cout << "Name: ";
puts(name);
return 0;
}42. Which keyword can be used in template?
43. Which are done by compiler for templates?
44. 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;
}
#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;
}45. How many types of linkages are there in C++?
46. Which of the following is correct about the shift?
47. 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;
}
#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;
}48. What is any in C++?
49. 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;
}
#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;
}50. Choose the correct formatted code.
Read More Section(C plus plus miscellaneous)
Each Section contains maximum 100 MCQs question on C plus plus miscellaneous. To get more questions visit other sections.
- C plus plus miscellaneous - Section 1
- C plus plus miscellaneous - Section 2
- C plus plus miscellaneous - Section 3
- C plus plus miscellaneous - Section 4
- C plus plus miscellaneous - Section 5
- C plus plus miscellaneous - Section 7
- C plus plus miscellaneous - Section 8
- C plus plus miscellaneous - Section 9
- C plus plus miscellaneous - Section 10
- C plus plus miscellaneous - Section 11
