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;
}
swap function is not defined
string is not defined here.
Variable n is not declared anywhere.
None
This question is part of this quiz :
String Data Structure Quiz for Beginners