What is the output of the following code fragment? The code is assumed
to be embedded in a correct and complete program.
int *p = a;
int i;
for (i = 0; i < 10; i++)
a[i] = i;
for (i = 0; i < 10; i++)
cout << p[i] << " ";
cout << endl;
Output:
Complete program code:
#include <iostream>
using namespace std;
int main()
{
int a[10];
int *p = a;
int i;
for (i = 0; i < 10; i++)
a[i] = i;
for (i = 0; i < 10; i++)
cout << p[i] << " ";
cout << endl;
system("pause");
return 0;
}