Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. void main()
  8. {
  9.    
  10.     int
  11.         number = NULL,
  12.         temp = NULL,
  13.         count = 1;
  14.  
  15.     string
  16.         input;
  17.  
  18.     cout << "Please enter a number: ";
  19.     getline(cin, input);
  20.  
  21.     number = temp = abs(atoi(input.c_str()));
  22.  
  23.  
  24.     while((number = number/10) > 0)
  25.     {
  26.         count++;
  27.     }
  28.  
  29.     number = temp;
  30.  
  31.     cout << number << " has " << count << " places." << endl;
  32.  
  33.     getline(cin,input);
  34.    
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement