Please explain answer 20. (12 pts) Finish the program below by adding a void fun
ID: 3604812 • Letter: P
Question
Please explain answer
20. (12 pts) Finish the program below by adding a void function as specified below. Add only a function prototype, function call statement and function definition to the following program The name of the void function is InitStruc The function has one parameter of the struct Data Type Name. The function is to initialize each member of the structure parameter with a value of "NoName". The information stored in the parameter must be available in main0 after the function call. #include using namespace std; struct Name string first; string middle; string last; // Place the function prototype below this line int main ) Name person; // Place the function call statement below this line return 0 Place the function definition below this lineExplanation / Answer
#include <iostream>
using namespace std;
struct Name {
string first;
string middle;
string last;
};
void InitStruct(struct Name &person);
int main() {
Name person;
InitStruct(person);
cout<<"First: "<<person.first<<endl;
cout<<"Middle: "<<person.middle<<endl;
cout<<"Last: "<<person.last<<endl;
return 0;
}
void InitStruct(struct Name &person) {
person.first = "NONAME";
person.middle = "NONAME";
person.last = "NONAME";
}
Output: