Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int zad26(){
  6. int liczba;
  7. cout<<"Podaj liczbe naturalna: ";
  8. cin>>liczba;
  9. while(liczba<=0) {
  10. cout << "Liczba musi byc naturalna." << endl;
  11. cout << "Podaj inna: ";
  12. cin >> liczba; }
  13.  
  14. int suma=0;
  15. int cyfra;
  16.  
  17.  
  18. do{
  19. cyfra=liczba%10;
  20. suma+=cyfra;
  21. liczba/10;
  22. cout<<suma;
  23. }while(liczba<0);
  24. }
  25.  
  26. int main() {
  27. cout<<zad26();
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement