Help Needed with Manual Testing Interview Questions

vantika vani's picture
vantika vani asked on March 28, 2023 - 9:21am | Replies (1).

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.

Thanks!

1 Answer

Zalika Williams's picture

Hi

I am not sure if you found a response to this question yet but I searched and found a reference that had the same question. 

Its from the site GeeksforGeeks.   They have the steps written in several different programming languages in case you need it. 

Here is the link:

https://www.geeksforgeeks.org/program-for-sum-of-the-digits-of-a-given-n...

I hope it helps and good luck on your interview.

Regards,

Z

StickyMinds is a TechWell community.

Through conferences, training, consulting, and online resources, TechWell helps you develop and deliver great software every day.