I need help with this C++ programming problem. Complete the second PrintSalutati
ID: 3768194 • Letter: I
Question
I need help with this C++ programming problem.
Complete the second PrintSalutation function to print the following given personName "Holly" and customSalutation "Welcome":
Here is the template for the problem please use it:
#include <iostream>
#include <string>
using namespace std;
void PrintSalutation(string personName) {
cout << "Hello, " << personName << endl;
return;
}
// Define void PrintSalutation(string personName, string customSalutation)...
void PrintSalutation
int main() {
PrintSalutation("Holly", "Welcome");
PrintSalutation("Sanjiv");
return 0;
}
Please explain your code as well. Thanks!
Explanation / Answer
Here is the code for you. If you need any further clarifications, just get back to me.
#include <iostream>
#include <string>
using namespace std;
void PrintSalutation(string personName) { //Given a single parameter.
cout << "Hello, " << personName << endl; //Prints Hello, followed by the parameter passed.
return;
}
// Define void PrintSalutation(string personName, string customSalutation)...
void PrintSalutation(string personName, string customSalutation)
{
cout<<customSalutation<<" "<<personName<<endl; //Prints the second parameter, followed by the first parameter.
}
int main() {
PrintSalutation("Holly", "Welcome"); //Calls a function PrintSalutation with 2 parameters.
PrintSalutation("Sanjiv"); //Calls a function PrintSalutation with 1 parameter.
return 0;
}