diff options
feat(Week13): Add solutions to most exercises
1 files changed, 17 insertions, 0 deletions
| -rw-r--r-- | Week13/Exercise03.cpp | 17 |
diff --git a/Week13/Exercise03.cpp b/Week13/Exercise03.cpp new file mode 100644 index 0000000..9dc4733 --- /dev/null +++ b/Week13/Exercise03.cpp @@ -0,0 +1,17 @@ +#include <iostream> + +unsigned digitSum(unsigned x) { + if (x == 0) + return 0; + else + return x % 10 + digitSum(x / 10); +} + +int main() { + unsigned num; + std::cin >> num; + + std::cout << digitSum(num) << std::endl; + + return 0; +} |
