I have a for
loop in my program that is not stopping:
vector<int> v;
int k = 1;
v.push_back(1);
for(int i=v.size()-1; i>=(v.size()-k); i--){
cout << i << " " << v.size() - k << endl;
}
When I execute the above program, it keeps running inside the for
loop. The output of the for
loop is as below:
0 0
-1 0
-2 0
-3 0
-4 0
.
.
.
As per the output, value of i
is decreasing and value of v.size()-k
is 0. So, i >= v.size()-k
is false, which should stop the for
loop to execute after the first round, But the for
loop doesn't stop executing.
Can someone help me understand this issue?