With your current algorithm the best solution would be to add a line counter that will determine the number of spaces. At the 0th line you print no spaces and for every newline you print, the counter gets incremented by one and you print that many spaces.
cnt = 0, i = 5: *****
cnt = 1, i = 3: ***
cnt = 2, i = 1: *
int i, j, k, cnt=0; char star='*';