Look at your
for
loop: it's what does the work.
At the moment you do this:
for (i = 0; i < count_to_generate; ++i) {
and a
for
loop has three parts, separated by ';' characters.
for (initialization ; termination check ; iterate)
"Initialization" lets you set a starting value: in your case zero.
"Termination check" lets you say when the loop will stop running: in your case when
i
is no longer less than your maximum value.
"Iterate" lest you specify what changes each time you go round the loop: in your case you increase
i
by one.
So to go down, change "Iterate":
i--
will subtract one instead of adding.
That means the "Termination check" needs to be changed:
i > 0
will end when you reach zero.
And then you need to change the start, so it works from your maximum:
i = count_to_generate
Which gives you:
for (i = count_to_generate; i > 0; i--) {
Easy, yes?