Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write value function fullName that accepts three string parameters as input: fir

ID: 3738729 • Letter: W

Question

Write value function fullName that accepts three string parameters as input: first name, middle name, and last name. If the middle name is not provided in the function call, use a default value of "Q". The function returns a string that combines the three name parts into one. Show two calls to fullName, one with three arguments and one with two arguments, and the value returned from each call.

a) Function declaration

         b) Function calls

Call

Value returned

Three-argument call

Two-argument call

Call

Value returned

Three-argument call

Two-argument call

Explanation / Answer

#include<iostream>


using namespace std;
string fullName (string, string , string="Q") ;
int main()
{
string name1 = fullName("Suresh","Murapaka","Kumar");
cout<<name1<<endl;
string name2 = fullName("Suresh","Murapaka");
cout<<name2<<endl;
return 0;
}
string fullName (string firstName, string lastName, string middleName) {
return firstName+" "+middleName+". "+lastName;
}

Output: