RAHUL_KUMAR
Member level 5
- Joined
- Jun 5, 2017
- Messages
- 90
- Helped
- 4
- Reputation
- 8
- Reaction score
- 4
- Trophy points
- 8
- Location
- Bhubaneswar,Odisha,India
- Activity points
- 780
what happen when the main() is called inside the body of the for loop
here on every true condition body of the for loop executed ,and on satisfying the condition ,main function is called , which again re-initializes the variable i with 0, hence its getting infinite loop.
my question is -- when the main function is called ,still it is inside the for loop,..because yet there is no false condition arrived ,.hence next time "i" variable must be incremented . but actually " i " is getting re-initialised.
what are background behaviour of main which let it to do so?
Code:
main()
{
for(i=0;i<10;i++)
main();
}
my question is -- when the main function is called ,still it is inside the for loop,..because yet there is no false condition arrived ,.hence next time "i" variable must be incremented . but actually " i " is getting re-initialised.
what are background behaviour of main which let it to do so?