i have a codelike this:
do
{
int i;
}while(i!=0);
Shows error "Cannot find symbol i"
Because i is defined within the loop and the condition of the lopp is, technically, outside the loop. A variable only "exists" within the scope in which it is created, in this case only inside the loop and not outside.
Edit: Do note, however, that a variable created outside the loop is visible within because the loop is contained within the scope in which the variable was created.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.