Advertisement
Abelsor

Contar Digitos

Mar 20th, 2023
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.20 KB | None | 0 0
  1.         //  Contar digitos
  2.        
  3. #include<iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int n;
  10.    
  11.     cin>>n;
  12.    
  13.     int cont = 0;
  14.    
  15.     while(n>0){
  16.         cont++;
  17.        
  18.         n = n/10;
  19.     }
  20.    
  21.     cout<<cont<<endl;  
  22. }
  23.  
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement