num is initialised to be zero only in the beginning.
After each iteration, its value changes as per the condition defined.
As a simplified example, you can see in the for loop, a variable is initialised to zero and then condition is provided and instructed to increment or decrement (usually) until the condition satisfies.
Initialising a variable to zero is to assign the value 0 to it if not, it will take the value of memory block.
2
solved Why would we multiply something by 10 if it’s zero