Pattern mountain logic

https://ide.codingblocks.com/s/83549
why is this code not working ?

if i use
for(p=1;p<=x;p++)
{
cout<<"\t";
}
x=x-2;
then it works
what is the difference btw the logic of these two??