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
module 4: Differentiate between Writing Functions for Array and Writing Functions for Structures.
Complete C++ the program provided to read football statistics into a structure array, offers a menu to update statistics, print data, and update a file.  The program declares a struct to store the data of a football player and has the following data members. The  structure in the header file provided: Name Position Number of Touchdowns Number of Catches Number of Passing Yards Number of Receiving Yards Number of Rushing Yards An array of the structure with 30 components is declared to store the data of football players. A function is provided to open the input file. A function skeleton is provided to read the data in the file “footballdata.txt” into the structure array. An Integer function is provided to search the structure array to find the index of a specific player. A function has been provided to using the index returned from the search, print all information for a player using the index returned from the search. A function has been provided to print all data for all players. A…
Programming: Simple Arrays Assignment Instructions   Overview You will use the enumerated type and a switch to calculate the weight someone would have on another planet.      Instructions   Use a functional decomposition to write a C++ program that asks the user to enter his or her weight and the name of a planet.   Use an enumerated type called planetType to represent the planets and use a switch statement that takes as its condition a planetType variable. The program, via the switch statement, then outputs to the screen how much the user would weigh on that planet. The following table gives the factor by which the weight must be multiplied for each planet.   Your program must have the following functions in it: GetUserInput() ConvertInputToPlanetType() OutputWeight() (your switch statement must be in OutputWeight()).   Determine what each function’s parameters and return types should be. The program will output an error message if the user does not type a correct planet…

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
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
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