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
Concept explainers
Question
Chapter 10.12, Problem 10.20CP
Program Plan Intro
Pointer:
Pointer is a special type of variable to store the address of the memory location, which can be accessed later.
- If an asterisk “*” operator is present before the variable, then that variable is referred as pointer variable.
- It is also called as dereferencing or indirection operator.
- Pointer is just a type of variable that stores the addresses of other variables.
- Using pointers, the address of a variable can be accessed and the data stored in that variable can be retrieved.
Syntax of pointer variable declaration:
<variable-type> *<variable-name>;
Usage of pointers to structures:
The usage of pointers to structure is same as declaring a pointer variable.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
В.width; }
{ t = B.type; w =
{ T.type = C.type; T.width = C.width; }
T → B
C
В > int
{ B.type = integer; B.width
4; }
В — foat
{ B.type = float; B.width =
8; }
{ C.type = t; C.width
= w; }
C - [ num] C1 = array(num. value, C1.type);
{ C.type
C.width
= num. value x C1. width; }
Write the definition of a pointer to a Rectangle structure.
Assume the following structure declaration exists
struct Rectangle
{
int length;
int width;
};
In C language
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
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
- /* 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_forwardFind errors / syntax error. Write line numberarrow_forward
- C++ Programming Problem: Newton is a brilliant mathematician and solving triangles problems fascinates him. Today he is given a sequence of positive integers V1, V2, ., VN. You must choose three elements Vx, Vy, Vz (x, y, z is vertices) such that the triangle formed have these properties: |XY|= Vz, |XZ|=Vy, |YZ|=Vx and the angle |ZYXZ|= 0 satisfies cose2P/Q, where 0 should be maximum possible. Find any such triangle or determine that it does not exist. Develop a C++ code which prints the value of x, y, z in a single line and print "Invalid" if not possible. Test Case: 412 9765 Result: 324arrow_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_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
- double tab1[5] = {2,3,4,5,6}; double tab2[5] = {6,5,4,3,2}; for(int i = 0;i<5;i++) { tab1[i] = tab1[i]*tab2[i]; cout<<tab1[i]<<" "; } 12 15 16 15 16 15 15 16 15 12 12 15 16 15 12 12 15 12 15 12arrow_forwardC++arrow_forward#include <stdio.h>#include <string.h>#define SIZE 6struct Cake {char name[50];float price;};int searchChoice(char *choice, struct Cake data[]);void displayChoice(int index, struct Cake data[]);int main() {char choice[50];int index;//Answer for Part (i) – Declare and initialise array stockprintf("What is your choice of cake? ");gets(choice);index = searchChoice(choice, stock);displayChoice(index, stock);return 0;}//Answer for Part (ii) – Function definition for searchChoice//Answer for Part (iii) – Function definition for displayChoicearrow_forward
- Fill-in-the-Blank A data structure that points to an object of the same type as itself is known as a(n) __________ data structure.arrow_forward#include <stdio.h> #include <stdlib.h> #include <string.h> #define EMPS_SIZE 20 #define SSN_SIZE 9 #define MAX_EMPS 19 typedef struct { int salary; int yearBorn; char ssn[SSN_SIZE]; char * name; } Employee; Employee * emps[EMPS_SIZE]; int totalEmps = 0; void main(void) { int end = 1; char * command; char buff[256]; char * findEmp; char findBuff[256]; char * sortType; char sortBuff[256]; char hire[] = "HIRE"; char list[] = "LIST"; char quit[] = "QUIT"; char find[] = "FIND"; char fire[] = "FIRE"; char _sort[] = "SORT"; char salary[] = "SALARY"; char name[] = "NAME"; char save[] = "SAVE"; printf("Welcome to the Employee Manager dashboard!\n"); while (end) { printf("Would you like to HIRE, LIST, FIND, FIRE, SORT,SAVE or QUIT?\n\n"); scanf("%s", buff); command = malloc(strlen(buff + 1)); strcpy(command, buff); printf("You entered the command: %s\n\n", command);…arrow_forwardC++ I need to create a 2D array map that can be displayed in the output like a 2D array visually.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