Write a structure declaration for a structure named Student that holds the following data about a student:
ID (int)
entry year (int)
GPA (double)
Then write definition statements that create the following two Student variables and initialize them using initialization lists.
Variable s1 should have ID number 1234, entry year 2008, and GPA 3.41.
Variable s2 should have ID number 5678 and entry year 2010. The GPA member should be left uninitialized.
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Starting Out With C++: Early Objects (10th Edition)
Additional Engineering Textbook Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Database Concepts (8th Edition)
Modern Database Management
Vector Mechanics for Engineers: Statics and Dynamics
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
- 3. Create 3 structures student, marks and university.Student should have name semester and grade.University should have student as its member and 1 more member need to be adress.Cin all the values and display them on screen. You can use member function of structure or you can directly display them by accessing separately.arrow_forwardSuppose that structures and variable p are declared as follows: struct new_struct{ char a; int b[10]; }; struct new_struct s; Which one of the following statements will update the 3rd element of b in the structure s to 34? s.b= 34; s.b[2] =34;arrow_forwardx = apple .code; set the value of code data member in the structure object apple to be equal to x assign the value of the data O member code in the structure object apple to the variable x compare the value of x to the value of data member apple.code multiply apple by code and assign the result to the variable xarrow_forward
- The member variables in a structure can have different data types.a. True b. Falsearrow_forwardMark the following statements as true or false. All members of a struct must be of different types. (1) A struct is a definition, not a declaration. (1) A struct variable must be declared after the struct definition. (1) A struct member is accessed by using the operator :. (2) The only allowable operations on a struct are assignment and member selection. (2) Because a struct has a finite number of components, relational operations are allowed on a struct. (2) Some aggregate input/output operations are allowed on a struct variable. (2) A struct variable can be passed as a parameter either by value or by reference. (4) A function cannot return a value of the type struct. (4) An array can be a member of a struct. (6, 7) A member of a struct can be another struct. (8)arrow_forwardAssume the pointer you defined in question 10.18 points to a valid Rectangle structure. Write the statement that displays the structure’s members through the pointer. Assume the following structure declaration exists struct Rectangle { int length; int width; };arrow_forward
- An Inventory structure is declared as follows: struct Inventory{int itemCode; int qtyOnHand;}; Write a definition statement that creates an Inventory variable named trivet and initializes it with an initialization list so that its code is 555 and its quantity is110.arrow_forwardwrite an expression that can be used to access the structure members in each of the following parts: d) Member firstName of the structure pointed to by customerPtr.arrow_forwardQ5: Write a C++ program that uses a structure to store records of cars. A car record contains seating_capacity (integer), model_year (string), car_type(String), and Engine_type as Eng. (Engine). The field Engine_type is of type Engine, a separately declared structure that contains three fields Capacity(int) in CC, Power (int) in horsepower, and No_of_cylenters(int). Now in main function you are required to declare a car C1, take input from user, for car_type, model_year, and car_type, Capicity, and show it as an output.Sample Input:Please enter car_type C1: Toyota SedanPlease enter model year for Toyota Sedan: 2020Please enter capacity for Toyota Sedan 2020: 1300Please enter power for Toyota Sedan: 200Sample Output:Toyota Sedan model 2020 is 1300 cc with 150 horsepowerarrow_forward
- Write a structure declaration for a structure named Account that holds the following data about a savings account. Include a constructor that allows data values to be passed in for all four members. Account number (string) Account balance (double) Interest rate (double) Average monthly balance (double) Now write a definition statement for an Account variable that initializes the members with the following data:Account number: ACZ42137 Account balance: $4512.59 Interest rate: 4% Average monthly balance: $4217.07arrow_forwardUse 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.arrow_forwardWrite a structure declaration for a structure named Account that holds thefollowing data about a savings account. Include a constructor that allows datavalues to be passed in for all four members.Account number (string)Account balance (double)Interest rate (double)Average monthly balance (double)Now wr ite a definition statement for an Account var iab le that initializes themembers with the following data :Account number: ACZ42137Account balance: $4512.59Inter est rate: 4%Average monthly balance: $4217 .07arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr