The isdigit ensures it cannot be negative, and this is C++ code which does need to declare variables before use.