I have a little problem with answer, computer is giving answer 2 4 6 8 while I am thinking that answer should be 2 6 only because value of count at start is 1 and after execution it will become 2 after multiplying with 2 and then it is incremented into 3. So next time by multiplying with 2 it should be 6 and loop should be ended because condition is no more true.
Why answer is different than my expectation, am I missing some point about loop mechanism?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
usingnamespace std;
int main()
{
int count = 1;
while (count < 5)
{
cout << (2 * count) << " ";
count++;
}
system("pause");
return 0;
}