0

If a 5 digit number is entered by a user. Write a program to calculate sum of its digits

without using loops and remainder theorem

19th Nov 2018, 5:40 PM
osama shabbir
osama shabbir - avatar
2 Respostas
+ 4
Hint: * Use std::to_string() to convert number to string * Ignore if string length not equal to 5 * Subtract each character by 48 to get the digit to add to sum variable.
19th Nov 2018, 6:15 PM
Ipang
+ 2
I think you should post it in coding challenges section
19th Nov 2018, 5:45 PM
Paul
Paul - avatar