Ive written this code in different ways and it doesnt work right if 100 is used in the prgram it works fine. It will count up or down to 100 or from 100 just fine. But when you put 1000 or 1000. For example : if i have the number 1000 in the program, it starts counting at 702 and not at 1. Code: #include<iostream> using namespace std; int main() { int number; for ( number = 1; number < 1001; number++) cout << number << "is this working" <<endl; system("pause"); return 0; } its also been written like this (and doesnt work) Code: #include<iostream> int main() { int number; for ( number = 1; number < 1001; number++) std::cout << number << "is this working" <<std::endl; system("pause"); return 0; } its also been written like this (and doesnt work) Code: #include<iostream> using namespace std; int main() { for ( int number = 1; number < 1001; number++) cout << number << "is this working" <<endl; system("pause"); return 0; } it's been written many ways and each time it doesnt work, it always starts of at 702 The thing I dont understand is why does it pick the number 702 to start counting from? again, with 100 it wont do this, it runs properly. With 1000 and 10000, ive tried using dopuble instead of in. no use. thank you
It works. Your output has merely overflowed the screen buffer because your screen buffer is not large enough. You can only scroll back to the beginning of the screen buffer, which, in your case, is where the 702 line is.
oh ok, thanks is there a way I can fix that so that i can go back too 1 or is that a fundemntal thing? if I write a program that goes to 10000 and it starts counting at 9702 to 10000, should I consider it working? thank you
You can increase the buffer size, but not indefinitely, of course. You could ask it to print every tenth line, or every 100th or 1000th, or whatever, by using the modulus operator. If you wanted to see them all, you could pause it after each line. I doubt you want to do that. The other thing you can do is write the output to a file instead of the screen.