+1 vote
in C Plus Plus by

What will be the output of the following C++ code?

  1.  #include <iostream>
  2.     #include <string>
  3.     #include <algorithm>
  4.     using namespace std;
  5.     int main() 
  6.     {
  7.         string s = "spaces in text";
  8.         s.erase(remove(s.begin(), s.end(), ' ' ), s.end() ) ;
  9.         cout << s << endl;
  10.     }

a) spacesintext
b) spaces in text
c) spaces
d) spaces in

1 Answer

0 votes
by

Answer: a
Explanation: In this program, We formed a algorithm to remove spaces in the string.
Output:

$ g++ dan.cpp
$ a.out
spacesintext

Related questions

0 votes
asked Oct 19, 2022 in C Plus Plus by AdilsonLima
0 votes
asked Mar 17, 2020 in C Plus Plus by SakshiSharma
...