Starting Out with C++ from Control Structures to Objects Plus MyLab Programming with Pearson eText -- Access Card Package (9th Edition)
9th Edition
ISBN: 9780134544847
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 9.5, Problem 9.5CP
Rewrite the following loop so it uses pointer notation (with the indirection operator) instead of subscript notation.
for (int x = 0; x < 100; x++)
cout ≪ arr[x] ≪ endl;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Rewrite the following loop so it uses pointer notation (with the indirection operator) instead of subscript notation.for (int x = 0; x < 100; x++)cout << arr[x] << endl;
Revise the program in Part I to use a pointer instead of an integer to keep track of the current 2 position in the array. Name the new C program as reverseP.c .
Question: 1) Put the source code of reverse.c and reverseP.c in your answer sheet.
2) In your answer sheet, please also attach screenshots of the outputs (note: you can type any messages you like)
Q1. Write a program to do the following : (1) Declare an array a of size 10 and three
pointer variables p, q, and v. (2)
Write a loop to fill array a with values 10, 20, 30, 40, 50, 60, 70, 80, 90, 100
(3) write following statement: p= &a[2]; q = &a[5]; i = *q - *p; cout<
Chapter 9 Solutions
Starting Out with C++ from Control Structures to Objects Plus MyLab Programming with Pearson eText -- Access Card Package (9th Edition)
Ch. 9.5 - Prob. 9.1CPCh. 9.5 - Write the definition statement for a variable...Ch. 9.5 - List three uses of the symbol in C++.Ch. 9.5 - What is the output of the following code? int x =...Ch. 9.5 - Rewrite the following loop so it uses pointer...Ch. 9.5 - Prob. 9.6CPCh. 9.5 - Prob. 9.7CPCh. 9.5 - Is each of the following definitions valid or...Ch. 9.9 - Prob. 9.9CPCh. 9.9 - Give an example of the proper way to call the...
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...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Write a method named quartersToDol1ars. The method should accept an int argument that is a number of quarters, ...
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
The following is the first line of the copy constructor definition for the class StringVar. The identifier Stri...
Problem Solving with C++ (9th Edition)
The spreadsheet in Microsoft Excel file Ch01Ex01_U10e.xlsx contains records of employee activity on special pro...
Using MIS (10th Edition)
What is the output produced by the following lines of program code? int quotient = 7/3; int reminder = 7/3; Sys...
Java: An Introduction to Problem Solving and Programming (7th Edition)
Falling Distance The following formula can be used to determine the distance an object falls due to gravity in ...
Starting Out with C++: Early Objects (9th Edition)
Essay Class Design an Essay class that extends the GradedActivity class presented in this chapter. The Essay cl...
Starting Out with Java: Early Objects (6th 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
- c program, Fill an array with 10 random integers between 0 & 100. Write a function that accepts this array and calculates both the minimum and maximum values in it. Print these values in the main() function. use pointersarrow_forwardWrite a recursive function named “oddRec” that takes the address of the array and the number of elements as a parameter and returns the number of odd numbers in the array. (Do not use global variable)arrow_forwardA pointer variable can contain a pointer to a single variable, a pointer to an array, nullptr, or a random value. Write code that creates and sets four pointer variables a, b, c, and d to show each of these possibilities.arrow_forward
- // Use pointer p to traverse the 2D array of characters variable 'strings' (input from user in main() ) and set all characters in each// array to a null terminator so that there is a 4 row and 50 column 2D array full of null terminators.// The null terminator '\0' is used to denote the end of a string.void initializeStrings(char strings[NUM_STRINGS][STRING_LENGTH]){ char *p = &strings[0][0]; // enter code here }arrow_forwardFinish the swap function below using pointers and write the call to swap in the reverse function using the address of the array positions array[i] and array[size-i-1].using pointers. DON'T FORGET TO DECLARE THE PARAMETERS in the function. (Hint: if you can't figure it out with pointers, do it with the references #include <iostream>using namespace std; // Function to swap two ints using pointers// @param pointer to an int// @param pointer to an intvoid swap( ) {// TODO: Add code that swaps two integers using pointers } // Function to reverse arrayvoid reverse(int a[], int size) {for (int i = 0; i < size/2; i++) {// TODO: write the call to swap in the reverse function using the // address of the array positions array[i] and array[size-i-1].arrow_forward"Array name can act as a constant pointer". Justify the given statement by distinguishng array name with pointer variable and suitable exmple.arrow_forward
- Write a function that uses a pointer to copy an array of size n. The data type of the array should be double. You can take input from the user, or you can use random variables. 6. Write a function that will receive a pointer to an array of floats of length n. The function will return the address of the maximum value in the array. need the solve in c++ languagearrow_forwardLook at the following C++ code and comment each line about how it works with pointer. int i = 33; double d = 12.88; int * iPtr = &i; double * dPtr = &d; // iPtr = &d; // dPtr = &i; // iPtr = i; // int j = 99; iPtr = &j; //arrow_forward1. Write a function called void swap with two parameters, which will receive the addressof x and y as pointer. The function should swap the value of x and y only if x is larger thany. Print the value of x and y after the function call. 2. Write a function called double getAverage(int *array, int SIZE), whereit accept the array as pointer, and return the average of the array. Print the returnedvalue from this function. Always use *array rather than subscript to access the arrayvalue.arrow_forward
- # Write a function to copy one array to another by using pointers. Comment/Discussion on the obtained results and discrepancies (if any).arrow_forwardstorage of strings through pointer saves memory space. justify your answer with an example.arrow_forwardC. In permutations and combinations, the term “n C r” refers to n combinationstaken r at a time.??? =?!/?! (? − ?)!Write a recursive function to find the factorial of a number.Use the defined function to compute the term “nCr” for the following scenario:The values of ‘n’ and ‘r’ are stored in two parallel arrays of any user definedsize . You have to Read the arrays n and r at run time. Compute n C r for eachcorresponding terms in the array ‘n’ and ‘r’, and display it properly formatted.Also your program should print the current date and time using libraryfunctionsarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License