C++ Assume that given , middle and family are three variables of type string tha
ID: 3862339 • Letter: C
Question
C++
Assume that given , middle and family are three variables of type string that have been assigned values . Write an expression whose value is a string consisting of the first character of given followed by a period followed by the first character of middle followed by a period followed by the first character of family followed by a period: in other words, the initials of the name . So if the values of these three variables were "John" "Fitzgerald" "Kennedy", then the expression 's value would be "J.F.K.".
Thank you
Explanation / Answer
string expression = first.at(0) + "." +middle.at(0)+"."+family.at(0)+".";
I hope this will do. the at() function finds the character at that position starting from 0th index.
The + operator concatinates the strings.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.