(Solved):What is the output? int a[] = {5, 7, 9, 2, 1, 2}; int *aPtr; aPtr = &a[0]; for (i=0; i<6; i++) { printf ("% d ", a[i]); } View Answer...

 

Question

What is the output?

int a = {5, 7, 9, 2, 1, 2};

int *aPtr;

aPtr = &{eq}a[0]

{/eq};

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

{ printf (“% d “, ai);

}

 

EXPERT ANSWER

You can check the commented code below:

#include <iostream>
using namespace std;
int main()
{
    // create array and initialize
    int a[] = {5, 7, 9, 2, 1, 2};
    // create new pointer
    int *aPtr;
    // new pointer shows the array
    aPtr = &a[0];
    // 6 times
    for (int i=0; i<6;

Scroll to top