hrdwareguy: dear oh dear, please read over my comment
Quote:
say it was i=1 to i<=5 instead of 500 so "
|
Its 2 to 501 because of the increment inside of the loop, before the while is tested.
For instance my example is 1 to 5 but it runs as 2 to 6. so when you do <=n , n ends up being + 1
i really don't know how to simplify it anymore so that you can understand it.
So heres another proof (hope this posts correctly) i added my comments with a // to the actual session
Code:
// show contents of file test.cpp ( i copied and pasted from hrdwareguys quote exactly as was )
[C:\4nt]type test.cpp
#include <stdio.h>
main()
{int count; count=1; while (count <= 500)
{++count;printf("I will not throw paper airplanes in class.\n");
}
return 0;
}
// compile it
[C:\4nt]cl -nologo test.cpp
test.cpp
// run it with a redirect into a file
[C:\4nt]test >out.txt
//run wc, which is a wordcounter with line count
[C:\4nt]wc out.txt
out.txt: Words: 4000 Lines: 500 Chars: 21000
Lines = 500 , as expected, i could post the whole output but that'd be silly.
I could post the exe if you still don't believe me, but if you go over the loop i typed it in the previous comment it will be come obvious to you (since it does seem like you didn't read it through as the comment you made indicates you didn't see where i said <=500 twice)