Pointer Program : Difference between two integer Pointers
#include<stdio.h> int main(){ float *ptr1=(float *)1000; float *ptr2=(float *)2000; printf("\nDifference : %d",ptr2-ptr1); return 0; }
Output :
Difference : 250
Explanation :
- Ptr1 and Ptr2 are two pointers which holds memory address of Float Variable.
- Ptr2-Ptr1 will gives us number of floating point numbers that can be stored.
ptr2 - ptr1 = (2000 - 1000) / sizeof(float) = 1000 / 4 = 250