Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
#include
3.
using namespace std;
4.
int main ()
5.
{
6.
string str ("nobody does like this");
7.
string key ("nobody");
8.
size_t f;
9.
f = str.rfind(key);
10.
if (f != string::npos)
11.
str.replace (f, key.length(), "everybody");
12.
cout
Options:
A .  nobody does like this
B .  nobody
C .  everybody
D .  everybody does like this
Answer: Option D

rfind is used to find the characters in the string and replace is used to replace with certain characters.
Output:
$ g++ stri2.cpp
$ a.out
everbody does like this



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers