KonradKonieczny

Funkcje - zadanie 23

Mar 31st, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int liczba_cyfr(int x)
  6. {
  7.     int warunek_zer=10;
  8.     int licznik_zer=1; //na pewno liczba bedzie miec przynajmniej 1 mniejsza od 10
  9.  
  10.     while(x>=warunek_zer)
  11.     {
  12.         warunek_zer*=10;
  13.         licznik_zer++;
  14.     }
  15.  
  16.     return licznik_zer;
  17. }
  18.  
  19. int main()
  20. {
  21.     int liczba=0;
  22.  
  23.     cout << "Podaj liczbe: "; cin>>liczba;
  24.     cout << "Liczba cyfr to: "<<liczba_cyfr(liczba);
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment