C++ A person\'s initials is the first letter of their first name, followed by a
ID: 3596645 • Letter: C
Question
C++ A person's initials is the first letter of their first name, followed by a period, followed by the first letter of their last name, followed by a period. For example, the initials for David Turner are D.T. Write a program that prompts the user for a first name and then prompt the user for a last name. Have the program display the user's initials. As part of your solution, define a function named initials, which takes 2 arguments: the first name and the last name. The function returns the person's initials as a string. Because the function arguments don't need to be changed and are complex data types, you should pass them into the function as const references. Hint: use the substr function or the index operator of the string data type.
Explanation / Answer
Public void initials(const string &firstname,const string &lastname){
Cout<<firstname[0]<<"."<<lastname[0];
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.