p
starts at 1.
You print the value of p, then check if it's zero.
If it isn't, you will go back around the loop.
But because you have a post-decrement on
p
before it actually makes the jump or not
p
is reduced by one.
It's the same thing as writing it like this:
#include <stdio.h>
int main()
{
int p=1;
while (p >= 0)
{
printf("%d",p);
p = p - 1;
}
return 0;
}
This may help:
Why Does x = ++x + x++ Give Me the Wrong Answer?[
^] - it explains what the pre- and post- increment / decrement operators actually do.