Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int zad26(){
- int liczba;
- cout<<"Podaj liczbe naturalna: ";
- cin>>liczba;
- while(liczba<=0) {
- cout << "Liczba musi byc naturalna." << endl;
- cout << "Podaj inna: ";
- cin >> liczba; }
- int suma=0;
- int cyfra;
- do{
- cyfra=liczba%10;
- suma+=cyfra;
- liczba/10;
- cout<<suma;
- }while(liczba<0);
- }
- int main() {
- cout<<zad26();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement