[Solved] How to correctly code this function such that it calculates the sum of each digit of the int? [closed]

[ad_1]

You never initialized sum. Value initialize it using int sum{} or int sum = x before trying to add d to it.

[ad_2]

solved How to correctly code this function such that it calculates the sum of each digit of the int? [closed]