C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 22, Problem 22.4E
Program Plan Intro
To Determine:
Definition for each of the following:
- Structure inventory, containing character array part name [30], integer part number, floating-point price, integer stock and integer reorder.
- A structure called address that contains character arrays street address [25], city [20], state [3] and zipcode [6].
- Structure student, containing arrays first name [15] and last name [15] and variable home address of type struct address from part (b).
- 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
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.
- 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.
- 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.
- 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.
- 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.
structInventory { charpartName[30]; intpartNumber; floatprice; intstock; intrecorder; };
structAddress { charstreetAddress[25]; charcity[20]; charstate[3]; charzipCode[6]; };
structStudent { charfirstName[15]; charlastName[15]; struct { charstreetAddress[25]; charcity[20]; charstate[3]; charzipCode[6]; } homeAddress; };
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)
Ch. 22 - Prob. 22.4ECh. 22 - Prob. 22.5ECh. 22 - (Shifting and Printing an Integer) Write a program...Ch. 22 - (Multiplication Via Bit Shifting) Left-shifting as...Ch. 22 - (Packing Characters into Unsigned Integers) The...Ch. 22 - (Unpacking Characters from Unsigned Integers)...Ch. 22 - Prob. 22.10ECh. 22 - Prob. 22.11ECh. 22 - (Determine the Value) The following program uses...Ch. 22 - Prob. 22.13E
Ch. 22 - Prob. 22.14ECh. 22 - (Converting Strings to Integers) Write program...Ch. 22 - Prob. 22.16ECh. 22 - (searching for Substrings) Write a program that...Ch. 22 - (Searching for Substrings) Write a program based...Ch. 22 - Prob. 22.19ECh. 22 - Prob. 22.20ECh. 22 - (ASCII Character Set) The chart in Appendix B...Ch. 22 - Prob. 22.22ECh. 22 - Prob. 22.23ECh. 22 - (Displaying Characters for Given ASCII Codes)...Ch. 22 - Prob. 22.25ECh. 22 - Prob. 22.26ECh. 22 - Prob. 22.27ECh. 22 - Prob. 22.28ECh. 22 - Prob. 22.29ECh. 22 - Prob. 22.30ECh. 22 - Prob. 22.31ECh. 22 - (Limericks) A limerick is a humorous five-line...Ch. 22 - Prob. 22.33ECh. 22 - Prob. 22.34ECh. 22 - Prob. 22.35ECh. 22 - Prob. 22.36ECh. 22 - Prob. 22.37ECh. 22 - Prob. 22.38ECh. 22 - Prob. 22.39ECh. 22 - Prob. 22.40ECh. 22 - Prob. 22.41ECh. 22 - (Word Processing) One important function in...Ch. 22 - (Printing Dates in Various Formats) Dates are...Ch. 22 - (Check Protection) Computers are frequently in...Ch. 22 - (Writing the Word Equivalent of a Check Amount)...Ch. 22 - (Morse Code) Perhaps the most famous of all coding...Ch. 22 - Prob. 22.47ECh. 22 - (Crossword Puzzle Generator) Most people have...Ch. 22 - (Spelling Checker) Many popular word-processing...
Knowledge Booster
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
- 1- Define a struct type that contains a person’s name consisting of a first name and a second name, plus the person’s phone number. Use this struct in a program that will allow one or more names and corresponding numbers to be entered and will store the entries in an array of structures. The program should allow a second name to be entered and output all the numbers corresponding to the name, and optionally output all the names with their corresponding numbers. *'Keep the program as simple as possible using the basic logic of struct the following images attached are just for some reference of what simple basic logic means in my words & also supposed to be applied when solving **single pointers & 2d arrays can be usedarrow_forwardDefine the expression "passing structure pointers."arrow_forward3. Define a structure array with three fields (name, age, year) and each field contains three values. Use struct2cell() and fieldnames() functions. 4. Define a function that accepts a structure array of dimensions 1x1 only and returns the number of its numeric scalar values. Hint: use isstruct() and. If the user requests an output. the function returns the number of the fields in the struct. solve in matlabarrow_forward
- Q.No.1. (Marks: 30) Write a complete C# console application in which you will have to store data of Employee in 1 dimensional array. Employee contains eid(int), name(string), department (string), gender (char) and salary (int) as properties. Size of array must be userdefined. You have to perform the following: • Input data in array. • Display data of highly paid female Employees • Pass the given array to function, so that it will return count of those employees whose department is IT. Pass the given array to function, so that it will return an array of employees working in IT department.arrow_forwardThis is a C program NOT C++ <3<3 This program will calculate the area of 6 rectangles. Create a structure called Area with values width, height and area. In the main() function: Create a structure variable array called Rectangle with 6 elements. Ask the user to enter values for width and height. Call function get_area(...) and pass the width and height. Display the data as per sample output. In function get_area(...): Calculate and return the area.arrow_forwardC++ Programming. OVERVIEW OF DATA STRUCTURES. Task: Write a program to process a data array. Execute a custom task as a separate function or method of a custom class. When performing a task, use functional methods for manually entering array elements, generating random numbers, and printing array elements. Given an array of size N. Create a function to determine the element that is furthest from the arithmetic mean of the array elements (that is, the maximum absolute difference).arrow_forward
- . Complete the program to processes an array of structured data. Complete those portions indicated in the template. The program has defined a structure named Sale. The structure has the following fields: string itemName int quantity double unitPrice The main function call loadUserlnput which returns a pointer to the first Sale element in the dynamically allocated array of Sale elements and an integer for the number of Sale elements in the array. The main function then calls printData to show the sale items including the total of cach sale item and the total of the entire list. Function printData This is the function you need to complete as well as two other helper functions. In the function body, print the report heading. Then iterate through the array received through the parameters and print the data according to the required format. For the total of each item, call getltemTotal. At the end of the report, print the total of the entire sale items by calling getTotal. Test The Program…arrow_forwardPlease fill in the blanks for C /* This function works with pointers and structures. All codes will be in main(). Define a struct time with 3 fields: hours, minutes, and seconds (all ints) in that order. */ /* Pointers and Structures*/ #include<stdio.h> //Define a structure of type struct time struct time { __1__ hours; __2__ minutes; __3__ seconds; }; int main() { //Declare 2 struct of type struct time called t1 and t2 __4__ __5__ t1, t2; //Declare a pointer-to-struct called pt of the same type __6__ __7__ __8__; //Initialize the pointer point to t1 __9__ = __10__; //Assign values to each member. No space!! //1. using t1 variable __11__ = 3; //hours __12__ = 15; //minutes __13__ = 59; //seconds //2. Using de-referecing pointer pt and period. Remember the () __14__ = 3;…arrow_forwardC++ Coding: ArraysTrue and False Code function definitions for eoNum() and output(): Both eoNum() and output() are recursive functions. output() stores the even/odd value in an array. Store 0 if the element in the data array is even and store 1 if the element in the data array is odd. eoNum() displays all the values in an array to the console.arrow_forward
- -C++ Program to know the dublicate elements in array. Code with comments and output screenshot is must ( PLAGIARISM will not be tolerated)arrow_forwardTask #01: Define a struct type that contains a person's name consisting of a first name and a second name, plus the person's phone number. Use this struct in a program that will allow one or more names and corresponding numbers to be entered and will store the entries in an array of structures. The program should allow a second name to be entered and output all the numbers corresponding to the name, and optionally output all the names with their corresponding numbers.arrow_forwardC++arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
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