• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

C | Pointer Basics | Question 6

C
#include<stdio.h>
int main()
{
    int arr[] = {10, 20, 30, 40, 50, 60};
    int *ptr1 = arr;
    int *ptr2 = arr + 5;
    printf(\"Number of elements between two pointer are: %d.\", 
                                (ptr2 - ptr1));
    printf(\"Number of bytes between two pointers are: %d\",  
                              (char*)ptr2 - (char*) ptr1);
    return 0;
}
Assume that an int variable takes 4 bytes and a char variable takes 1 byte

(A)

Number of elements between two pointer are: 5. Number of bytes between two pointers are: 20

(B)

Number of elements between two pointer are: 20. Number of bytes between two pointers are: 20

(C)

Number of elements between two pointer are: 5. Number of bytes between two pointers are: 5

(D)

Compiler Error

(E)

Runtime Error

Answer

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments