In your first sample code, space should be initialised as 2*num-1, and not num (e.g., if num is 3, the line must be length 5 to get the last line right). In the first inner loop you then need to write two spaces each time, not one, and decrement space by 2, not by 1 each time.
Not sure what you intend to do when num reaches double digits.
Can you post the code that gave you your last result. If you have decremented space by 2 as I suggested, I don't see how it can go from 4 spaces at the front to 1.
so that it does the other two things I suggested: write TWO spaces (not 1, as above) and decrement space by 2 (your code above decrements by 1; use the -= composite operator if you like).
Also, to make it compile on all c++ compilers, please add the header #include <cstdlib>
or it may not allow system() to be used.
Go back to outputting a single space in line 16.
space needs to be decremented (by 2) outside of the inside2 loop - after the cout << endl;
line would do.
Again, please accept my apologies - I should have tried more numbers. Should work then up to num=9, but double digits are a different matter.