Hello,
I have been trying to count the number of digits in an integer. I know I am close, but I am not quite sure what I am doing wrong. Could someone please point me in the right direction?
My output is always 1 for A. I know I am just misunderstanding something simple.Code:using namespace std; int main() { long A; long B; int n=0; cout << "enter value: " ; cin >> A; cin.ignore(); if (1000000000 < A >= 0) { ++n; (A /= 10); cout << A << " is " << n << " digits long" << endl; } }
Thank you in advance for any help on this problem.