Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
single_digit
#include <iostream> using namespace std; int single(int n,int sum) { if (n==0) { return sum; } else { sum=sum+n%10; n=n/10; return single(n,sum); } } int main() { int n,sum=0; cout<<"Enter a non-negative integer : "<<endl; cin>>n; sum=single(n,sum); cout<<"The sum of all digits "<<n<<" is : "<<sum<<endl; system ("pause"); }
run
|
edit
|
history
|
help
0
QuickSort
Gauss v1.1
Stream4
Изволов#7
VecHotel
random
Addition of two matrix **Part 1
LRUCache
new delete malloc free
Bit count in number