Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <cstdio>
  4.  
  5. using namespace std;
  6. //loops - exercises
  7.  
  8. main()
  9. {
  10. beginning:
  11. system("cls");
  12. int var1;
  13. int nrOfDigits = 1;
  14.  
  15. cout << "Input number: " << endl;
  16. cin >> var1;
  17.  
  18. int tmp = var1;
  19. while(tmp /= 10)
  20. nrOfDigits++;
  21.  
  22.  
  23. cout << "The number " << var1 << " has " << nrOfDigits << " digits" << endl;
  24.  
  25. char decision;
  26.  
  27. cout << "Do you want to try again? (Y/N)" << endl;
  28. cin >> decision;
  29.  
  30. if (decision == 'y' || decision == 'Y')
  31. goto beginning;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement