StringAppend (Write in C++): Write a full program that reads a string entered by
ID: 3713771 • Letter: S
Question
StringAppend (Write in C++):
Write a full program that reads a string entered by the user. Do not provide any prompt for the user, the user will know to start typing a string.
Once the input has been received, write a function called stringAppend that receives a string passed by reference as input and has no output. The function should append to the parameter the text " is a super coder."
You program should call your function and then output the modified string ending with a newline
Be sure to include all necessary headers.
Note: While possible to complete this task without writing the function, on the exam you will lose points for not writing the corresponding function.
Explanation / Answer
#include <iostream>
using namespace std;
void stringAppend (string &s) {
s = s + " is a super coder";
}
int main() {
string s ;
getline(cin , s);
stringAppend(s);
cout<<s<<endl;
}
Outut:
Suresh is a super coder