Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 10.12, Problem 10.19CP
Assume the following structure declaration exists for quest ions 10.18 through 10.20:
struct Rectangle
{
int length;
int width;
};
10.19 Assume 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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write the definition of a pointer to a Rectangle structure.
Assume the following structure declaration exists
struct Rectangle
{
int length;
int width;
};
Assume 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;
};
C code Blocks
Select all of the code segments that are the correct way to define a variable class as an array of 185 personal structures.
struct personal { int id; // id numberchar name[80];};
Options:
a .personal class[185];
b. struct personal class[185];
c. typedef struct personal classStruct;classStruct class[185];
d. typedef class[185];
Chapter 10 Solutions
Starting Out With C++: Early Objects (10th Edition)
Ch. 10.5 - Prob. 10.1CPCh. 10.5 - Write a statement defining a variable dPtr. The...Ch. 10.5 - List three uses of the symbol in C++.Ch. 10.5 - What is the output of the following program?...Ch. 10.5 - Rewrite the following loop so it uses pointer...Ch. 10.5 - Prob. 10.6CPCh. 10.5 - Assume pint is a pointer variable. For each of the...Ch. 10.5 - For each of the following variable definitions,...Ch. 10.10 - Assuming array is an array of ints, which of the...Ch. 10.10 - Give an example of the proper way to call the...
Ch. 10.10 - Complete the following program skeleton. When...Ch. 10.10 - Look at the following array definition: const int...Ch. 10.10 - Assume ip is a pointer to an int. Write a...Ch. 10.10 - Assume ip is a pointer to an int. Write a...Ch. 10.10 - Prob. 10.15CPCh. 10.10 - Prob. 10.16CPCh. 10.10 - Prob. 10.17CPCh. 10.12 - Prob. 10.18CPCh. 10.12 - Assume the following structure declaration exists...Ch. 10.12 - Prob. 10.20CPCh. 10 - Each byte in memory is assigned a unique _____Ch. 10 - The _____ operator can be used to determine a...Ch. 10 - Prob. 3RQECh. 10 - The _____ operator can be used to work with the...Ch. 10 - Prob. 5RQECh. 10 - Creating variables while a program is running is...Ch. 10 - Prob. 7RQECh. 10 - If the new operator cannot allocate the amount of...Ch. 10 - Prob. 9RQECh. 10 - When a program is finished with a chunk of...Ch. 10 - You should only use the delete operator to...Ch. 10 - What does the indirection operator do?Ch. 10 - Look at the following code. int X = 7; int ptr =...Ch. 10 - Name two different uses for the C++ operator.Ch. 10 - Prob. 15RQECh. 10 - Prob. 16RQECh. 10 - Prob. 17RQECh. 10 - What is the purpose of the new operator?Ch. 10 - What happens when a program uses the new operator...Ch. 10 - Prob. 20RQECh. 10 - Prob. 21RQECh. 10 - Prob. 22RQECh. 10 - Prob. 23RQECh. 10 - Prob. 24RQECh. 10 - Prob. 25RQECh. 10 - Prob. 26RQECh. 10 - What happens when a unique_ptr that is managing an...Ch. 10 - What does the get ( ) method of the unique_ptr...Ch. 10 - Prob. 29RQECh. 10 - Prob. 30RQECh. 10 - Prob. 31RQECh. 10 - Prob. 32RQECh. 10 - Consider the function void change(int p) { P = 20;...Ch. 10 - Prob. 34RQECh. 10 - Write a function whose prototype is void...Ch. 10 - Write a function void switchEnds(int array, int...Ch. 10 - Given the variable initializations int a[5] = {0,...Ch. 10 - Each of the following declarations and program...Ch. 10 - Prob. 39RQECh. 10 - Test Scores #1 Write a program that dynamically...Ch. 10 - Test Scores #2 Modify the program of Programming...Ch. 10 - Indirect Sorting Through Pointers #1 Consider a...Ch. 10 - Indirect Sorting Through Pointers #2 Write a...Ch. 10 - Pie a la Mode In statistics the mode of a set of...Ch. 10 - Median Function In statistics the median of a set...Ch. 10 - Movie Statistics Write a program that can be used...Ch. 10 - Days in Current Month Write a program that can...Ch. 10 - Age Write a program that asks for the users name...Ch. 10 - Prob. 10PC
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is the sign of the quotient when a positive number is divided by a negative number?
Digital Fundamentals (11th Edition)
Book Club Points Serendipity Booksellers has a book club that awards points to its customers based on the numbe...
Starting Out with Programming Logic and Design (4th Edition)
Type in and run the five programs presented in this chapter. Compare the output produced by each program with t...
Programming in C
The startsWith, endsWith, and regionMatches methods are members of this class. a. String b. Char c. Character d...
Starting Out with Java: Early Objects (6th Edition)
Why might doctors and nutritionists be interested in a device like DietSensor?
Using MIS (10th Edition)
Practice Problem 3.57 (solution page 350) Function funct3 has the following prototype: double funct3(int ap, do...
Computer Systems: A Programmer's Perspective (3rd Edition)
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
- Question 2 You are about to create a simple 2D shooting game. i) Create appropriate structures with the following information: Bullet isAvailable: bool Gun type: The gun type (e.g. Rifles or Pistol) bulletSize: Total bullets in the gun (e.g. 6 bullets in Pistol) bullets: An array of Bullet type. Maximum 100 bullets applied in the game. ii) Assume you have defined a variable called myWeapon as follows: Gun myWeapon; myWeapon.model "Machine Gun"; myWeapon.size 80; Write a code fragment to reload all the gun bullets status to true. iii) Create a function called shot that takes in a reference parameter as Gun type. The function displays the message "Reload" if the first bullet is empty. Otherwise, for every single bullet, it displays "Bang" and set the last bullet to false.arrow_forwardDrink Machine Simulator Write a program that simulates a soft drink machine. The program should use a structure that stores the following data: Drink Name Drink Cost Number of Drinks in Machine The program should create an array of five structures. The elements should be initialized with the following data: Drink Name Cost Number in Machine Cola .75 20 Root Beer .75 20 Lemon-Lime .75 20 Grape Soda .80 20 Cream Soda .80 20 Each time the program runs, it should enter a loop that performs the following steps: A list of drinks is displayed on the screen. The user should be allowed to either quit the program or pick a drink. If the user selects a drink, he or she will next enter the amount of money that is to be inserted into the drink machine. The program should display the amount of change that would be returned, and subtract one from the number of that drink left in the machine. If the user selects a drink that has sold out, a message…arrow_forwardActivity 1 This program firstly initializes an object of struct Cirele with values and then updates those using pointers. The program uses structure notation once and pointer notation another afterwards. #include #include #define MIN 1 #define MAX 30 struct Circle { float xCoord; float yCoord; float radius; }; /* prototypes */ float getRandomNumber (int min, int max); void printByValue(struct Circle cirobj); void setValue(float *target, float newValue); void printByReference(struct Circle *cirObj); int main(void) { /* Declare a struct circle and name it circleobject */ struct Circle circleObject; /* Fill circleObject's members with random numbers */ circleobject.xCoord = getRandomNumber(MIN, MAX); circleobject.yCoord = getRandomNumber (MIN, MAX); circleobject.radius = getRandomNumber (MIN, MAX); /* Printing values of the circle by calling function print by value */ printByValue(circleobject); /* update values of circle one by one */ setValue (&circleobject.xCoord, getRandomNumber(MIN,…arrow_forward
- #ifndef lab5ExF_h #define lab5ExF_h typedef struct point { char label[10]; double x ; // x coordinate for point in a Cartesian coordinate system double y; // y coordinate for point in a Cartesian coordinate system double z; // z coordinate for point in a Cartesian coordinate system }Point; void reverse (Point *a, int n); /* REQUIRES: Elements a[0] ... a[n-2], a[n-1] exists. * PROMISES: places the existing Point objects in array a, in reverse order. * The new a[0] value is the old a[n-1] value, the new a[1] is the * old a[n-2], etc. */ int search(const Point* struct_array, const char* target, int n); /* REQUIRES: Elements struct-array[0] ... struct_array[n-2], struct_array[n-1] * exists. target points to string to be searched for. * PROMISES: returns the index of the element in the array that contains an * instance of point with a matching label. Otherwise, if there is * no point in the array that its label matches the target-label, * it should return -1. * If there are more than…arrow_forwardDeclare the following structure in a program, along with two instances (s1 and s2) as indicated: struct my_struct { int a; float b; } s1, s2; In the program declare a pointer to the structure. Ask the user to enter the values for each structure. Then, using the pointer, print the values of each structure s1 and s2. Don’t access the structure variables directly.arrow_forwardASSIGNMENT: Student Data Write a program that uses two structures Name and Student to store the following information for multiple students: 1. Create a NAME structure that consists of • First Name, • Middle Initial, and • Last Name. 2. Create a STUDENT structure that contains student information (Include the NAME structure within the Student information structure) o Name o ID o email • SSN • Program (an enum type containing programs such as CSCI, DBMS, INFM, SDEV)arrow_forward
- /* Movie List Example --Showing how to use vectors and structures */ #include <iostream> #include <iomanip> #include <string> #include <vector> using namespace std; // define a struct for a Movie object struct Movie // It is common for the struct name to be capitalized { string title = ""; // First member of structure - and initialized int year = 0; // Second member of structure - and initialized }; int main() { cout << "The Movie List program\n\n" << "Enter a movie...\n\n"; // get vector of Movie objects vector<Movie> movie_list; char another = 'y'; while (tolower(another) == 'y') { Movie movie; // make temporary new (initialized) Movie object cout << "Title: "; getline(cin, movie.title); cout << "Year: "; cin >> movie.year; movie_list.push_back(movie);…arrow_forward/* Movie List Example --Showing how to use vectors and structures */ #include <iostream> #include <iomanip> #include <string> #include <vector> using namespace std; // define a struct for a Movie object struct Movie // It is common for the struct name to be capitalized { string title = ""; // First member of structure - and initialized int year = 0; // Second member of structure - and initialized }; int main() { cout << "The Movie List program\n\n" << "Enter a movie...\n\n"; // get vector of Movie objects vector<Movie> movie_list; char another = 'y'; while (tolower(another) == 'y') { Movie movie; // make temporary new (initialized) Movie object cout << "Title: "; getline(cin, movie.title); cout << "Year: "; cin >> movie.year; movie_list.push_back(movie);…arrow_forwardClass and Data members: Create a class called Student that stores a student’s grades (integers) in a vector (do not use an array). The class should have data members that store a student’s name and course for which the grades are earned. Constructor(s): The class should have a 2-argument constructor that receives the student’s name and course as parameters and sets the appropriate data members to these values. Member Functions: The class should have functions as follows: Member functions to set and get the student’s name and course variables. A member function that adds a single grade to the vector. Only positive grades are allowed. Call this function AddGrade. A member function to sort the vector in ascending order. A member function to compute the average (x̄) of the grades in the vector. The formula for calculating an average is x̄ = ∑xi / n where xi is the value of each grade and n is the total number of grades in the vector. A member function to determine the lowest…arrow_forward
- A structure called citizen is defined. Declare an array of type citizen of size 41.arrow_forwardCreate a structure representing a student object with the following members regno. courseid unitsRegistered: This should be an array of the course units you registered to capture marks unitsmarks: This should be an array to store the marks for the units registered. Find a way to relate the two. firstname surname address By using the structure above, write a program that populates the details of a student and compute the average, and the grade as well as the total marks. This task should be accomplished by writing functions for getData() - to populate the structure, printStudent() - to display the detail of the student, computeGrade() - to compute the grade of the student and computeMean() that computes the mean of the students: Pass the appropriate data NB: The function getData() - is a subroutine and uses structure as a reference - input, same concept to printData() Consider that your class has 10 students. Compute the class mean and standard deviation, highest class mark and lowest…arrow_forwardDeclare a student structure that contains : Student's first and last nameStudent IDCreate the following functions: getStudentInfo(void) Declares a single student, uses printf()/scanf() to get inputReturns the single student backprintStudentInfo(student_t *st_ptr) Takes the pointer to a student (to avoid making a copy)Prints out all of the student informationDeclare an array of five studentsUsing a for loop and getStudentInfo() function, get input of all the studentsUsing a for loop and printStudentInfo() function, print all the output of all students.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 Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Structured Chart; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=vdUO-sGA1DA;License: Standard YouTube License, CC-BY
Introduction to Structure Charts; Author: Christopher Kalodikis;https://www.youtube.com/watch?v=QN2bjNplGlQ;License: Standard Youtube License