Cout not printing in for loop
I cant seem to print int x within the for loop. Can anyone tell me why is cout not working inside a for loop?
1 2 3 4 5 6 7 8 9 10 11 12 13
|
#include <iostream>
using namespace std;
int main()
{
for (int x = 5; x < 5; x++)
{
cout << x << endl;
}
return 0;
}
|
It's not working because x is never less than 5.
How many times do you think the loop is going to execute?
Hint: Never. If x starts at 5, the termination condition is never true.
Topic archived. No new replies allowed.