Question: Write statements to initialize all the array elements to their index values using the pointer (p) Write statements to print all the array elements to

Write statements to initialize all the array elements to their index values using the pointer (p)

Write statements to print all the array elements to the screen using the array name (a)

#include "stdafx.h"

#include

using namespace std;

typedef int* IntPtr;

int main ()

{

IntPtr p;

int a[10];

int index;

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

a[index] = index;

p=a;

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

cout << p[index] << " ";

cout << endl;

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

p[index] = p[index] + 1;

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

cout << a[index] << " ";

cout << endl;

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

cout << 9 - index << " ";

cout << endl;

system ("pause");

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!