Ask Question

Write c+ + function that receives input a person's first name and surname, and then just displays the initials. For example: John Peter Joe, the initials JPJ must be displayed

+4
Answers (1)
  1. 31 July, 02:06
    0
    void Initials (string firstName, string lastName)

    {

    cout<
    for (int i=1; i
    {

    if (firstName[i-1]==' ')

    {

    cout<
    }

    }

    cout<
    for (int i=1; i
    {

    if (lastName[i-1]==' ')

    {

    cout<
    }

    }

    cout<
    }

    Explanation:

    The above written code is the function Initials which prints the full name. Parameters provided in the function are firstname and lastname in the format of string. You should include string header file for this code to run.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write c+ + function that receives input a person's first name and surname, and then just displays the initials. For example: John Peter ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers