C++ How to Program (10th Edition)
C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
bartleby

Videos

Question
Book Icon
Chapter 22, Problem 22.4E
Program Plan Intro

To Determine:

Definition for each of the following:

  1. Structure inventory, containing character array part name [30], integer part number, floating-point price, integer stock and integer reorder.
  2. A structure called address that contains character arrays street address [25], city [20], state [3] and zipcode [6].
  3. Structure student, containing arrays first name [15] and last name [15] and variable home address of type struct address from part (b).
  4. Structure test, containing 16 bit fields widths of 1 bit. The names of the bit fields are the letters a to p.

Expert Solution & Answer
Check Mark

Explanation of Solution

Explanation:

Defining Structures:

Structure is nothing but the collection of different variables of different types. First we need to define a structure in the program, for that we need to use the keyword struct and then the name of the structure. The name under which we want to combine different-different variables or different-different elements and between the curly braces whatever we write or whatever variables we declare will be considered as the members of the structure. All the members will be available under this one name of the structure. Declaring or defining the member of a structure is similar to the way we declare the variables.

  1. Here we are storing the information of Inventory, so the structure name will be Inventory and all the members are available under this one name Inventory.
  2. structInventory
    {
    	charpartName[30];
    	intpartNumber;
    	floatprice;
    	intstock;
    	intrecorder;
    };
  3. Here we are storing the information of Address, so the structure name will be Address and all the members are available under this one name Address.
  4. structAddress
    {
    	charstreetAddress[25];
    	charcity[20];
    	charstate[3];
    	charzipCode[6];	
    };
  5. Here we are storing the information of Student, so the structure name will be Student and all the members are available under this one name Student.
  6. structStudent
    {
    	charfirstName[15];
    	charlastName[15];
    	struct
    	{
    		charstreetAddress[25];
    		charcity[20];
    		charstate[3];
    		charzipCode[6];
    	}
    	homeAddress;
    };
  7. Here we are storing the information of Test, so the structure name will be Test and all the members are available under this one name Test.
  8. structTest
    {
    	boola:1, b:1, c:1, d:1, e:1, f:1, g:1, h:1,
    	i:1, j:1, k:1, l:1, m:1, n:1, o:1, p:1;
    };

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Provide the definition for each of the following structures and unions: 4) Structure student that contains arrays firstName[ 15 ] and lastName[ 15 ] and variable
In C programming language Question (Array of Structures) a) Write a program that declares a structure student with the following data members; Name (String) RollNo(Integer) CGPA(Float) b) Create an array s1 of 5 elements in main function of type structure student c) Initialize all the structures stored within array. d) Print all array contents.
Use C++ codingNested Structures: Define a structure for Student containing information about name, roll number, address. The Address is itself another structure containing house no., street no., sector no., phase no., city name. Using arrays declare two addresses for the student: one address is for temporary address and second one is for permanent address. Declare one student structure variable and using pointer to this structure variable take input from the user to enter the information about the student.

Chapter 22 Solutions

C++ How to Program (10th Edition)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License