Hi, I'm a beginner in c++ and need some help in my code.
I tried to write the code below for the program that asks a user to enter a number in the range 1-99 an outputs digital root of the number entered.
But it doesn't work properly. I've found some codes to write such program, but
I'd like to know what is wrong with my code. Can anyone please explain in what part I have a mistake ?
Thank you for the answer, but I'd like to know why my code outputs wrong results. I repeated the same operation twice (calculating sum of digits) using one function in another. But it outputs wrong results, for example, for 75 digital root is 3, but I get 4. And yes I would like to calculate it in this way.
The problem is that you caclulate the sum of number_2 in sum_of_digits_2(...) twice, but you need the sum of the last calculated the second time. This only when the result from the last calculation was greater nine.