Question 1
What is the output of the following code?
#include <iostream>
using namespace std;
int main()
{
string str1 = "Hello";
string str2 = "Geeks";
string str3 = str1 + str2;
cout << str3 << endl;
return 0;
}
Question 2
What is the output of the following code?
#include <iostream>
using namespace std;
int main()
{
string str = "Hello";
cout << str.substr(2, 5);
return 0;
}
Question 3
What is the output of the following code?
#include<bits/stdc++.h>
using namespace std;
int main()
{
// Write C++ code here
char str_array2[] = "Geeks";
cout << sizeof(str_array2) << " ";
char str_array[] = { 'G', 'e', 'e', 'k', 's'};
cout << sizeof(str_array);
return 0;
}
Question 6
What will the output of the following questions:
#include <bits/stdc++.h>
using namespace std;
int main()
{
string a = "Hello";
string b = "World";
string c = b.append(a);
cout << c << endl;
return 0;
}
Question 7
What is missing in the given code?
#include <bits/stdc++.h>
using namespace std;
void reverseStr(string& str)
{
for (int i = 0; i < n / 2; i++)
swap(str[i], str[n - i - 1]);
}
// Driver program
int main()
{
string str = "geeksforgeeks";
reverseStr(str);
cout << str;
return 0;
}
There are 20 questions to complete.