difference b/w variable Declaration inside and outside the for loop

Hi,
i am a student and i am also interested in programming. i have a confusion in mind about loops. please solve here.


what is difference (memory allocation or any) b/w declaring a variable inside or outside the variable


program1:


#include<stdio.h>
int main()
{
int i;
for (i=0;i=<100;i++)
{
//statements
}
}

program2:
#include<stdio.h>
int main()
{
for (int i=0;i=<100;i++)
{
//statements
}
}



can anyone explain difference b/w program1 and program2.
its look both are same. but my compiler shows something difference.
Topic archived. No new replies allowed.