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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started