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 ("steve jobs is legend");
7.
string::iterator it;
8.
str.erase (str.begin()+ 5, str.end()-7);
9.
cout
Options:
A .  jobs is
B .  steve legend
C .  steve
D .  none of the mentioned
Answer: Option B

In this program, We are leaving the first 5 characters and last 7 characters and we are erasing 

the remaining the characters.
Output:
$ g++ stri3.cpp
$ a.out
steve legend



Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers