There's so much wrong in that code.
First of all, as pointed out in the answer by M.M, the code will not even compile without raising a diagnostic message from the compiler. If it does, your compiler is misconfigured or non-standard. Assigning a int* to a char* is not a valid form of assignment (see "simple assignment" 6.5.16.1). Neither is the opposite, char *p=a;.
Even if the code was rewritten as valid C, for example like this:
int i = *((int*)(p+1));
it would still be highly questionable code. First of all, if this results in a misaligned access, the code might invoke undefined behavior (6.3.2.3/7). Second, such code would violate strict pointer aliasing and invoke undefined behavior for that reason too (6.5/7).
And finally, given that p is a char*, the code printf("%d",*p); invokes undefined behavior because %d is not a valid conversion specifier for character pointers (7.21.6.1/9).
So there's no less than four possible cases of entirely different forms of undefined behavior in two rows of code... kind of impressive.
Now, if we assume that your particular system does not have any issues with misaligned access and that you have some non-standard compiler which doesn't follow the rules of pointer aliasing...
If so, on a 32 bit system, the array could get allocated in one of two possible ways:
02 00 00 00 03 00 00 00 04 00 00 00 // little endian
00 00 00 02 00 00 00 03 00 00 00 04 // big endian
In that case your first printf would print 2 or 0, depending on system, since it points at the very first byte, and you print the pointed-at contents of that byte.
If you then increment the char pointer by 1 and somehow manage to read the pointed-at contents as a 32 bit integer, you would get the data
00 00 00 03 // little endian
00 00 02 00 // big endian
Which equals the decimal values 50331648 (little) and 512 (big) respectively. Now what you wish to prove with that, or how the whole algorithm would be meaningful, I have no idea. There's not much to learn from this practice, apart from studying the many ways that will cause this code to fail.
a[]looks like in memory. (Also note that you appear to be running this program on a little endian architecture).p+1incrementspby as many bytes the type it points is long.sizeof()forintandcharp=(int *)(p+1);is undefined behavior (UB) as it can violate alignment requirements. Code may crash