Look at the following structure declaration. struct FullName { char lastName[26]; char middleName[26]; char firstName[26]; }; Write statements that A) Define a FullName structure variable named info B) Assign your last, middle, and first name to the members of the info variable C) Display the contents of the members of the info variable

Short Answer

Expert verified
Answer: To display the contents of the members of the "info" variable, use the printf function from the stdio.h library as follows: ```c #include printf("Last Name: %s\n", info.lastName); printf("Middle Name: %s\n", info.middleName); printf("First Name: %s\n", info.firstName); ```

Step by step solution

01

Define a FullName structure variable named info

To define a FullName structure variable named "info", use the following statement: ```c struct FullName info; ```
02

Assign your last, middle, and first name to the members of the info variable

To assign your names to the members of the "info" variable, use strcpy function from the string.h library. Include the string.h library and copy the names to the respective members as follows: ```c #include strcpy(info.lastName, "Doe"); strcpy(info.middleName, "Smith"); strcpy(info.firstName, "John"); ``` Make sure to replace "Doe", "Smith", and "John" with your personal last, middle, and first names.
03

Display the contents of the members of the info variable

To display the contents of the members of the "info" variable, use the printf function from the stdio.h library. Include the stdio.h library and print the contents as follows: ```c #include printf("Last Name: %s\n", info.lastName); printf("Middle Name: %s\n", info.middleName); printf("First Name: %s\n", info.firstName); ``` By following these steps, you will successfully define the FullName structure variable, assign values to its members, and display the contents.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Study anywhere. Anytime. Across all devices.

Sign-up for free