adplus-dvertising
frame-decoration

Question

What is the output of C Program with arrays and pointers?
int main()
{
    int ary[] = {10,20,30}, *p;
    p = &ary[0];
    int i=0;
    while(i<3)
    {
        printf("%d ", *p);
        p++;
        i++;
    }
    return 0;
}

a.

10 10 10

b.

10 20 20

c.

10 20 30

d.

randomvalue randomvalue randomvalue

Posted under C Programming

Answer: (c).10 20 30

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of C Program with arrays and pointers?