Advertisement
LukaszPanko

Zadanie 24

Mar 29th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int SUMA_CYFR(int l)
  6. {
  7.    int s=0;
  8.         do
  9.             {
  10.             s=s+l%10;
  11.             l=l/10;
  12.             }
  13.         while(l!=0);
  14.         return s;
  15. }
  16.  
  17. int main()
  18. {
  19.     int liczba;
  20.     int liczba1=liczba;
  21.     cout << "Podaj liczbe: ";
  22.     cin>>liczba;
  23.     cout<<"Suma cyfr wynosi: ";
  24.     cout<<SUMA_CYFR(liczba)<<endl;
  25.     if(SUMA_CYFR(liczba)>=10){
  26.             liczba1=SUMA_CYFR(liczba);
  27.         cout<<"Suma cyfr wynosi: ";
  28.     cout<<SUMA_CYFR(liczba1)<<endl;
  29.     }
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement