Home » C++ Programming » Strings » Question
  1. What is the output of this program?
    #include <iostream>
    #include <string>
    using namespace std;
    int main ()
    {
    string s ("Ajit Kumar");
    unsigned found = s.find_first_of("Gupta");
    while (found != string :: npos)
    {
    s[found] = '*';
    found = s.find_first_of("Gupta", found + 1);
    }
    cout << s << '\n';
    return 0;
    }
    1. Ajit Kumar
    2. Gupta
    3. Compilation Error
    4. Runtime Error
    5. Segmentation fault
Correct Option: E

In this program, We are replacing the vowels with a asterisk by using find_first_of method.



Your comments will be displayed only after manual approval.