OK, let's rip out the "extras" and just look at the flow control stuff:
for(i=1;i<=rows;++i)
{
for(space=1;space<=rows-i;++space)
{
}
while(k!=2*i-1)
{
if (count<=rows-1)
{
}
else
{
}
}
}
So you have an outer loop:
for(i=1;i<=rows;++i)
{
...
}
Which contains two inner loops:
for(space=1;space<=rows-i;++space)
{
}
while(k!=2*i-1)
{
...
}
Which are executed one after the other - the first
for
loop runs, then the
while
loop runs when the
for
loop is complete.
Inside the second loop, you have a conditional which means that one side or the other will be executed each time it goes round.
Try it: use the debugger, and put a breakpoint on the first line of the code. When you run your program, it will stop when it hits the breakpoint and let you decide what to do next. Simply stepping each lien through will show you exactly what is happening!
(I can't tell you how to set a breakpoint or step a line, because that will depend on which development IDE you are using - google for "breakpoint" and the name of your IDE and you should find it pretty easily).