Output of the program
enter the word : I am a girl
Enter another string : boy
Enter the position to replace the word : 3
I am a boy .
This is the output .
Brief explanation :
I have initially taken the word into a character array and have copied it to a vector<string> , Then I have taken another string.
I have finally taken a position value from the user and have replaced the second word with position value .
1. Read the strings into an ordered collection (like a vector).
2. Use the index to identify the element of the collection to be replaced.
3. Overwrite the indexed element with the new word.
4. Write out the sentence from the collection.