Q541
Open question#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.
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.
Q541
Open question#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.
Q542
Open questionSelect an option to see the answer and solution.
Q543
Open questionSelect an option to see the answer and solution.
Q544
Open question#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.
Q545
Open questionSelect an option to see the answer and solution.
Q546
Open questionSelect an option to see the answer and solution.
Q547
Open question#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.
Q548
Open questionSelect an option to see the answer and solution.
Q549
Open question#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.
Q550
Open questionOptions are not available for this question.
Select an option to see the answer and solution.
Q551
Open question#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.
Q552
Open questionSelect an option to see the answer and solution.
Q553
Open questionSelect an option to see the answer and solution.
Q554
Open questionSelect an option to see the answer and solution.
Q555
Open question#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.
Q556
Open questionSelect an option to see the answer and solution.
Q557
Open questionSelect an option to see the answer and solution.
Q558
Open questionSelect an option to see the answer and solution.
Q559
Open questionSelect an option to see the answer and solution.
Q560
Open questionSelect an option to see the answer and solution.