ExamVeda
Login
Home
This question belongs to C Program Pointer
Pointer
?

Find the output of the following program.
void main()
{
   int array[10];
   int *i = &array[2], *j = &array[5];
   int diff = j-i;
   printf("%d", diff);
}

Answer & Solution
Correct Answer: Option A

When subtracting pointers you get the number of elements between those addresses, not the number of bytes.

Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.