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
Question
Chapter 10, Problem 17RQE
Program Plan Intro
Pointer:
Pointer will allow the user to indirectly access and manipulate the variable data contents. A pointer variable will hold the address of the data contents. If an asterisk “*” operator is present before the variable then that variable is referred as pointer variable. An asterisk “*” is also referred as indirection operator is used to dereferences the pointer.
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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
comprog
true or false
C# application that will allow users to enter values store all the expenses on that month in an array
clothes, food, cool drinks, water, meat
comprog array declaration
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
Similar questions
- int grades[100]; int i; for (i=0;i <= 100;i++) { grades[i) = 100; } The above C++ code is the proper way to initialize the grades array, TRUE or FLASE True Falsearrow_forward#include <iostream>#include<iomanip>using namespace std; int main(){ const int ROW_HOURS=6; //declare variables const int CL_PAYRATE=2; double total_payout=0; double hours[ROW_HOURS][CL_PAYRATE]={ //declare array {0,12.85}, {0,12.85}, {0,12.85}, {0,11.75}, {0,11.75}, {0,11.15} }; cout<<fixed; cout<<setprecision(2); //setprecision of double values upto 2 decimal point for(int i=0;i<6;i++) //using loop get input from user { cout<<"Enter the hours worked by employee "<<i+1<<": "; cin>>hours[i][0]; //store values into hours } for(int i=0;i<6;i++) { double payout=hours[i][0]*hours[i][1]; //calculate payout of emplyee total_payout=total_payout+payout;…arrow_forward1. Array Allocator Write a function that dynamically allocates an array of integers. The function should accept an integer argument indicating the number of elements to allocate. The function should return a pointer to the array.arrow_forward
- T/F 8) In Java, an array can only store one type of data. For instance, you cannot create an array that stores both doubleand String values.arrow_forwardT/F 8) A single form of data may be stored in an array in Java. You can't make an array that holds both double and String values, for example.arrow_forwardCASE STUDY#:Grade Register Write a grade register program to keep and process the grades of students. The program contain a class called GradeRegister. This class has two data members known as CourseName and an array of integer called Grades. The array Grades keep the grades of students of the same course. GradeRegister class have three methods as GetHighestGrade(), GetLowestGrade() and GetAverageGrade().The method GetHighestGrade return the maximum grade as integer from the array Grades and GetLowestGrade return the minimum grade value as integer from the array Grades. The GetAverageGrade method will return the average of grades from Grades array as float value. The parameterized constructor inside GradeRegister class will take two parameters to initialize the two data members of same class as mentioned before. Write a driver class GradeRegisterDriver to declare and initialize an integer array for grades and pass through the GradeRegister class constructor along with the course name.…arrow_forward
- Lotto Program C++Write a program that simulates the Powerball lottery. In Powerball, a ticket is comprised of 5 numbers between 1 and 69 that must be unique, and a Powerball number between 1 and 26. The Powerball does not have to be unique. Hint: You can use an array to represent the 5 unique numbers between 1 and 69, and an integer variable to represent the powerball. The program asks the player if they'd like to select numbers or do a 'quickpick', where the numbers are randomly generated for them. If they opt to select numbers, prompt them to type the numbers in and validate that they are unique (except the powerball), and in the correct range. The program then generates a 'drawing' of 5 unique numbers and a Powerball, and checks it against the user's lotto ticket. It assigns winnings accordingly. Because it is so rare to win the lottery, I suggest hard coding or printing values to when testing the part of the program that assigns winnings.arrow_forwardLargest/Smallest Array Values Write a program that lets the user enter 10 values into an array. The program should then display the largest and smallest values stored in the array. Do question 7(above) again this time using 5 functions. void getValues(int [], int); void displayValues(const int[], int); int largest(const int[],int); int smallest(const int[],int); void displayLargestSmallest(int,int);arrow_forward#include <iostream> #include<string.h> //user-defined functions question! using namespace std; struct Books { char title[50]; char author[50]; char subject[100]; int book_id; }; int main() { double array1[5]= {13.768,4.0,88.7689,9.12,}; struct Books Book1; strcpy( Book1.title, "C++ Programming"); strcpy( Book1.author, "D.S Malik"); strcpy( Book1.subject, "C++ basics"); Book1.book_id = 6495407; ////Block#1////// int x=4; for (x; x>=0; x--){ cout<<array1[x]<<endl; //////////////////////////////// } cout<<"///////////////////////"<<endl; ////end of Block#1////// ////Block#2////// int sum=0, i=0; for (i; i<5; i++){ cout<<static_cast<int>(array1[i])<<" "; sum= sum+array1[i]; cout<<sum<<endl; } cout<< "final value of sum="<<" "<<sum<<endl; cout<< "the average value ="<<" " <<sum/5 <<endl; cout<<"//////////////////////"<<endl; //arrow_forward
- #include <iostream> #include<string.h> //user-defined functions question! using namespace std; struct Books { char title[50]; char author[50]; char subject[100]; int book_id; }; int main() { double array1[5]= {13.768,4.0,88.7689,9.12,}; struct Books Book1; strcpy( Book1.title, "C++ Programming"); strcpy( Book1.author, "D.S Malik"); strcpy( Book1.subject, "C++ basics"); Book1.book_id = 6495407; ////Block#1////// int x=4; for (x; x>=0; x--){ cout<<array1[x]<<endl; //////////////////////////////// } cout<<"///////////////////////"<<endl; ////end of Block#1////// ////Block#2////// int sum=0, i=0; for (i; i<5; i++){ cout<<static_cast<int>(array1[i])<<" "; sum= sum+array1[i]; cout<<sum<<endl; } cout<< "final value of sum="<<" "<<sum<<endl; cout<< "the average value ="<<" " <<sum/5 <<endl; cout<<"//////////////////////"<<endl; //arrow_forwardAn array definition reserves space for the array. true or falsearrow_forwardTo receive an array argument, a function's parameter list must specify that the function expects to receive an array. The size of the array is not required between the array brackets. Select one: True Falsearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning