Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
Question
Book Icon
Chapter 9.2, Problem 12STE
Program Plan Intro

Pointer in C++:

A pointer is a variable whose value will be another variable’s address. Generally, a pointer variable is declared as follows:

type *var-name;

Here, type is the pointer’s base type and var-name is the pointer variable name. The asterisk is used to designate a variable as a pointer.

Given Program:

//Include libraries

#include <iostream>

//Use namespace

using namespace std;

//Define main method

int main()

{

// Declare array

int a[10];

// Declare variable

int *p = a;

// Declare variable

int i;

//Loop executes until the value of i exceeds 10

for (i = 0; i < 10; i++)

//Assign value i to a[i]

a[i] = i;

//Loop executes until the value of i exceeds 10

for (i = 0; i < 10; i++)

//Display value

cout << p[i] << " ";

cout << endl;

//Pause console window

system("pause");

//Return 0 value

return 0;

}

Blurred answer
Students have asked these similar questions
Download the file Ackermann.cpp. Inside the file the recursive Ackermann function is implemented (described in Chapter 14 Programming Challenge 9). Do the following and answer the three questions: a) Run the program. What happens?b) Now uncomment the code that is commented out and run the program again. What happens now?c) What do you think is going on?
Write these in Pseudocode  #1a – In pseudocode, write a call to a function that passes 1 Integer variable and 1 Integer array, and saves a Boolean value in return.   #1b – In pseudocode, write the function that accepts 1 Integer and 1 Integer array and returns a Boolean.     In the function, search the Integer array with a for-loop, and if the Integer parameter is found in the array, return false. If the Integer parameter is not found, return true.                                                                                               #2a – In pseudocode, write a call to a module that passes 1 Integer variable, 1 Real variable, 1 String constant, and 1 String literal as arguments.    #2b – In pseudocode, write the module header that accepts 1 Integer, 1 Real, and 2 Strings as parameters.        #3 – This pseudocode has multiple problems. Fix the calling statement and the definition below so that the routine accepts 3 grades as parameters and returns the average into a variable.…
nbm.m//,//
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr