Ask Question
18 June, 01:02

Write a program that has the following String variables: firstName, middleName, and lastName. Initialize these with your first, middle, and last names. The program should also have the following char variables: firstInitial, middleInitial, and lastInitial. Store your first, middle, and last initials in these variables. The program should display the contents of these variables on the screen.

+2
Answers (1)
  1. 18 June, 01:54
    0
    The programming language is not stated; However, I'll answer your question using C+ + programming language.

    Comments are used for explanatory purpose

    Program starts here

    #include

    #include

    using namespace std;

    int main ()

    {

    //Declare Variables

    string firstName, middleName, lastName;

    char firstInitial, middleInitial, lastInitial;

    /*Initialize firstName, middleName and lastName (Replace values with your details) * /

    firstName = "First Name";

    middleName = "Middle Name";

    lastName = "Last Name";

    / / Get Initials

    firstInitial = firstName. at (0);

    middleInitial = middleName. at (0);

    lastInitial = lastName. at (0);

    //Print Results

    cout<<"Lastname: "<
    cout<<"Firstname: "<
    cout<<"Middlename: "<
    cout<<"Last Initial: "<
    cout<<"First Initial: "<
    cout<<"Middle Initial: "<
    return 0;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a program that has the following String variables: firstName, middleName, and lastName. Initialize these with your first, middle, and ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers