#include "stdafx.h"
#include <iostream>
using namespace std;
void func(void);
static int count = 10;
int main()
{
while(count--)
{
func();
}
return 0;
}
void func(void)
{
static int i = 5;
i++;
cout << "i is " << i;
cout << " and count is " << count << endl;
}
//this programs output is://
i is 6 and count is 9
i is 7 and count is 8
i is 8 and count is 7
i is 9 and count is 6
i is 10 and count is 5
i is 11 and count is 4
i is 12 and count is 3
i is 13 and count is 2
i is 14 and count is 1
i is 15 and count is 0
My question is, "Why does the while loop stop? What exactly is the condition that makes the loop terminate? Why is this not an infinite loop?"