Two problems in your initial code. First,
while ( i < 0 && i > 24 ). In your test, when will a number ever be less than 0 AND greater than 24 at the same time? BTW, I believe the limit is 23, not 24.
Next, a more subtle issue. You have declared i inside a pair of curly braces, i.e., the do loop. This defines the scope of the variable i. THat means that i doesn't exist outside of those curly braces. If you delcare i before the do loop, so that it is scoped for the entirety of main, your undeclared variable error will go away.
If this answers your question, please click the check mark and accept. Let's keep up on forum maintenance. ;-)