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
4149 coj WIP
Hello World
Perfect Square Solution
NameTempSpecial2
Stock buy/sell, maximum subarray problem
GCC bug #79511
poprawione_i_podzielone_1
First and last Occurence of an Element
half diamond or pyramid
a