STARTING OUT C++,+MATLAB+MYPROGRAMLAB>C
STARTING OUT C++,+MATLAB+MYPROGRAMLAB>C
19th Edition
ISBN: 9781323948637
Author: GADDIS
Publisher: PEARSON C
Question
Book Icon
Chapter 9.9, Problem 9.9CP

A)

Program Plan Intro

Address of (&) operator:

The main purpose of address operator “&” operator in pointers is to return the memory address of variables.

When the address of operator “&” is placed before the pointer variable, it will hold address of the pointer variable.

Example Program:

//include necessary header

#include <iostream>

#include <string>

using namespace std;

//main method

int main()

{

//variable declaration

int a;

//display the address of the variable a

cout << &a;

}

Representing array using pointer notation:

  • In general, array will have a continuous allocation of memory bytes, to represent the values present in the array it can be represented using its subscript value.
  • So, to represent the values using pointer notation with an indirection operator the name of the array plus the subscript representing the value needs to be specified.
  • When we represent only the array name, it will indicate the first element of the array.
  • To represent the next element we need to increment the values by one to find the proceeding elements of the array.
  • When “&” operator is used before an array it will return the address of the corresponding value.

B)

Program Plan Intro

Address of (&) operator:

The main purpose of address operator “&” operator in pointers is to return the memory address of variables.

When the address of operator “&” is placed before the pointer variable, it will hold address of the pointer variable.

Example Program:

//include necessary header

#include <iostream>

#include <string>

using namespace std;

//main method

int main()

{

//variable declaration

int a;

//display the address of the variable a

cout << &a;

}

Representing array using pointer notation:

  • In general, array will have a continuous allocation of memory bytes, to represent the values present in the array it can be represented using its subscript value.
  • So, to represent the values using pointer notation with an indirection operator the name of the array plus the subscript representing the value needs to be specified.
  • When we represent only the array name, it will indicate the first element of the array.
  • To represent the next element we need to increment the values by one to find the proceeding elements of the array.
  • When “&” operator is used before an array it will return the address of the corresponding value.

C)

Program Plan Intro

Address of (&) operator:

The main purpose of address operator “&” operator in pointers is to return the memory address of variables.

When the address of operator “&” is placed before the pointer variable, it will hold address of the pointer variable.

Example Program:

//include necessary header

#include <iostream>

#include <string>

using namespace std;

//main method

int main()

{

//variable declaration

int a;

//display the address of the variable a

cout << &a;

}

Representing array using pointer notation:

  • In general, array will have a continuous allocation of memory bytes, to represent the values present in the array it can be represented using its subscript value.
  • So, to represent the values using pointer notation with an indirection operator the name of the array plus the subscript representing the value needs to be specified.
  • When we represent only the array name, it will indicate the first element of the array.
  • To represent the next element we need to increment the values by one to find the proceeding elements of the array.
  • When “&” operator is used before an array it will return the address of the corresponding value.

D)

Program Plan Intro

Address of (&) operator:

The main purpose of address operator “&” operator in pointers is to return the memory address of variables.

When the address of operator “&” is placed before the pointer variable, it will hold address of the pointer variable.

Example Program:

//include necessary header

#include <iostream>

#include <string>

using namespace std;

//main method

int main()

{

//variable declaration

int a;

//display the address of the variable a

cout << &a;

}

Representing array using pointer notation:

  • In general, array will have a continuous allocation of memory bytes, to represent the values present in the array it can be represented using its subscript value.
  • So, to represent the values using pointer notation with an indirection operator the name of the array plus the subscript representing the value needs to be specified.
  • When we represent only the array name, it will indicate the first element of the array.
  • To represent the next element we need to increment the values by one to find the proceeding elements of the array.
  • When “&” operator is used before an array it will return the address of the corresponding value.

Blurred answer
Students have asked these similar questions
Identify error(s), if any, in the following array declarations. If a statement is incorrect, provide the correct statement. a. int primeNum[99];b. int testScores[0];c. string names[60];d. int list100[0..99];e. double[50] gpa;f. const double LENGTH = 26;double list[LENGTH - 1];g. const long SIZE = 100;int list[2 * SIZE];
Javascript programming question below  Write the pseudocode for an application that will:a. Prompt a user for three numbers.b. Store the values entered by a user in an array as they are provided bythe user.c. Ask a user if they would like to search for a value:i. If the user wishes to search for a value, the user needs to beprompted for a value to search for.  If the value is found, anotification needs to be provided to the user.d. Use a for loop to cycle through the arrays in order to calculate anddisplay the total of the values stored in the array.
This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team. (1) Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers in one int array and the ratings in another int array. Output these arrays (i.e., output the roster). Ex: Enter player 1's jersey number: 84 Enter player 1's rating: 7 Enter player 2's jersey number: 23 Enter player 2's rating: 4 Enter player 3's jersey number: 4 Enter player 3's rating: 5 Enter player 4's jersey number: 30 Enter player 4's rating: 2 Enter player 5's jersey number: 66 Enter player 5's rating: 9 ROSTER Player 1 -- Jersey number: 84,Rating: 7 Player 2 -- Jersey number: 23, Rating: 4 ... (2) Implement a menu of options for a user to modify the roster. Each option is represented by a single character. The program initially outputs the menu, and outputs the menu after a user chooses an option. The…

Chapter 9 Solutions

STARTING OUT C++,+MATLAB+MYPROGRAMLAB>C

Ch. 9.9 - Complete the following program skeleton. When...Ch. 9.9 - Look at the following array definition: const int...Ch. 9.9 - Assume ip is a pointer to an int. Write a...Ch. 9.9 - Prob. 9.14CPCh. 9.9 - Prob. 9.15CPCh. 9.9 - Prob. 9.16CPCh. 9.9 - Prob. 9.17CPCh. 9 - What does the indirection operator do?Ch. 9 - Look at the following code. int x = 7; int iptr =...Ch. 9 - So far you have learned three different uses for...Ch. 9 - Prob. 4RQECh. 9 - Prob. 5RQECh. 9 - Prob. 6RQECh. 9 - What is the purpose of the new operator?Ch. 9 - What happens when a program uses the new operator...Ch. 9 - Prob. 9RQECh. 9 - Prob. 10RQECh. 9 - Prob. 11RQECh. 9 - Prob. 12RQECh. 9 - Each byte in memory is assigned a unique...Ch. 9 - The _________ operator can be used to determine a...Ch. 9 - Prob. 15RQECh. 9 - The ________ operator can be used to work with the...Ch. 9 - Array names can be used as ________, and vice...Ch. 9 - Prob. 18RQECh. 9 - The ________ operator is used to dynamically...Ch. 9 - Under older compilers, if the new operator cannot...Ch. 9 - Prob. 21RQECh. 9 - When a program is finished with a chunk of...Ch. 9 - You should only use pointers with delete that were...Ch. 9 - Prob. 24RQECh. 9 - Look at the following array definition: int...Ch. 9 - Prob. 26RQECh. 9 - Assume tempNumbers is a pointer that points to a...Ch. 9 - Look at the following function definition: void...Ch. 9 - Prob. 29RQECh. 9 - Prob. 30RQECh. 9 - Prob. 31RQECh. 9 - T F The operator is used to get the address of a...Ch. 9 - T F Pointer variables are designed to hold...Ch. 9 - T F The symbol is called the indirection...Ch. 9 - T F The operator dereferences a pointer.Ch. 9 - T F When the indirection operator is used with a...Ch. 9 - T F Array names cannot be dereferenced with the...Ch. 9 - Prob. 38RQECh. 9 - T F The address operator is not needed to assign...Ch. 9 - T F You can change the address that an array name...Ch. 9 - T F Any mathematical operation, including...Ch. 9 - T F Pointers may be compared using the relational...Ch. 9 - T F When used as function parameters, reference...Ch. 9 - T F The new operator dynamically allocates memory.Ch. 9 - T F A pointer variable that has not been...Ch. 9 - Prob. 46RQECh. 9 - T F In using a pointer with the delete operator,...Ch. 9 - Prob. 48RQECh. 9 - Prob. 49RQECh. 9 - int x, ptr = nullptr; ptr = x;Ch. 9 - Prob. 51RQECh. 9 - Prob. 52RQECh. 9 - Prob. 53RQECh. 9 - float level; int fptr = level;Ch. 9 - Prob. 55RQECh. 9 - Prob. 56RQECh. 9 - Prob. 57RQECh. 9 - Prob. 58RQECh. 9 - int pint = nullptr; pint = new int[100]; //...Ch. 9 - Prob. 60RQECh. 9 - Prob. 61RQECh. 9 - Prob. 62RQECh. 9 - Array Allocator Write a function that dynamically...Ch. 9 - Test Scores #1 Write a program that dynamically...Ch. 9 - Drop Lowest Score Modify Problem 2 above so the...Ch. 9 - Test Scores #2 Modify the program of Programming...Ch. 9 - Prob. 5PCCh. 9 - Case Study Modification #1 Modify Program 9-19...Ch. 9 - Case Study Modification #2 Modify Program 9-19...Ch. 9 - Mode Function In statistics, the mode of a set of...Ch. 9 - Median Function In statistics, when a set of...Ch. 9 - Reverse Array Write a function that accepts an int...Ch. 9 - Array Expander Write a function that accepts an...Ch. 9 - Element Shifter Write a function that accepts an...Ch. 9 - Movie Statistics Write a program that can be used...
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
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
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning