Advertisement
icatalin

Suma cifrelor

Nov 8th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.22 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void sum_cif(int x,int &suma)
  6. {
  7.  
  8.   while (x)
  9. { suma=suma+x%10;
  10.  x/=10;
  11. }
  12.  
  13. }
  14.  
  15. int main()
  16. {
  17.     int suma=0;
  18.     sum_cif(53223,suma);
  19.     cout<<suma;
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement