Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



#include<stdio.h>
void main()
{
    int arr[]={1, 2, 3, 4, 5};
    int *p = arr;

    printf("%d", *p++);
    printf("%d", *(p+1));
}
Find the output of the above code?





Solution

Initial:


arr = {1,2,3,4,5}

p → arr[0]


First statement:


*p++


Post-increment


Value printed = *p = 1

Then pointer moves to next element.


Now:


p → arr[1]


Second statement:


*(p+1)


p+1 → arr[2]


Value = 3


Output:


1 3



Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...