csansoon

P2.07 P55622 Number of digits (1)

Sep 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.22 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main () {
  5.     int n;
  6.     cin >> n;
  7.     int i=10;
  8.     int d=1;
  9.    
  10.     while (n/i!=0) {
  11.         i*=10;
  12.         d++;
  13.     }
  14.     cout << "The number of digits of " << n << " is " << d << "." << endl;
  15. }
Add Comment
Please, Sign In to add comment