diff --git a/src/digitSum.cpp b/src/digitSum.cpp new file mode 100644 index 0000000..85b2ea6 --- /dev/null +++ b/src/digitSum.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; +class digitSum +{ + public: + int getSum(int n) + { + int sum=0; + while(n!=0) + { + sum=sum+n%10; + n/=10; + } + return sum; + } +}; \ No newline at end of file