I want to get a detailed explanation on the difference between using %d and %p type for printing pointer.
Also
Why does
Those conversions are highly architecture dependent. One of the most clear distinctions are with the real mode 8086 where int is 16 bits and a (large model) pointer is 32 bits but has a segment and offset which are always written as segment:offset.
%d takes 16 bits and displays it as a signed value 123
%p takes a pointer and display it in address format 0fef:0004
Since %p was introduced relatively recently I don't know of any implementations but a PDP-11 library ought to implement it by display the 16-bit address in octal.