Advertisement
Guest User

Untitled

a guest
May 1st, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. /*
  2. Description: This small but slightly useful program
  3. calculates how long a int is in characters which can
  4. be useful for spacing of graphs outputted in plain text.
  5. */
  6. #include <iostream>
  7.  
  8. using namespace std;
  9.  
  10. int main(int argc, char *argv[])
  11. {
  12. int in = 0;
  13. int out = 0;
  14.  
  15. cout << "Please input a number:";
  16. cin >> in;
  17.  
  18. while(1)
  19. {
  20. if(in >= 10)
  21. {
  22. in /= 10;
  23. out++;
  24. }else{
  25. out++;
  26. break;
  27. }
  28. }
  29. cout << out;
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement