Hello all,I'm preparing for a manual testing interview and I'm having some trouble figuring out how to answer some of the questions. I'm especially stuck on a particular question involving writing code. I referred to this resource. The question is:
"Write a program that takes an integer as an input and prints the sum of all the digits in the input number."I've tried this code, but it doesn't seem to be working:int number, sum = 0;court << "Enter an integer: ";
in >> number;
while (number != 0)
sum += (number % 10);
number /= 10;
court << "The sum of the digits is: " << sum << endl;
Can anyone help me figure out what I'm doing wrong? Any advice or tips would be greatly appreciated.