You never initialized sum
. Value initialize it using int sum{}
or int sum = x
before trying to add d
to it.
solved How to correctly code this function such that it calculates the sum of each digit of the int? [closed]
You never initialized sum
. Value initialize it using int sum{}
or int sum = x
before trying to add d
to it.
solved How to correctly code this function such that it calculates the sum of each digit of the int? [closed]