Recently, I created a program that was supposed to check the number of digits in the amount entered by the user. As a result, I made the following code:
int x; cout << "Enter a number: "; cin >> x; x /= 10; while(x > 0) { count++; x = x/10; }
From what I can say (even with my limited experience), is that he seems rude and rather inelegant.
Does anyone have an idea on how to improve this code (without using the built-in C ++ function)?
source share