Ask Question

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. 31 March, 00:15
    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 & 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