So, I have a question. I'm about a week into this whole C++ nonsense, and I'm beginning to see something I didn't expect. As far as programming experience, I'm pretty good at QBASIC, and TBASIC; programming calculators. In both of those languages, the console reads the code top down, going from each line to the next and executing the code until it sees a :goto Lbl .
That being said, that's my understanding of programming. So, in a basic counting program like below, is that the methodology used? Does the console read the code and execute starting with the first thing it sees?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
usingnamespace std;
int main ()
{
long n, a;
a = 0;
cout << "What number would you like to count to?";
cin >> n;
while (a < n)
cout << a << endl, a=a+1;
while (a < 0)
cout << "Error, please enter a positive number";
if (n = a)
cout << n;
return 0;
}
Perhaps a better question, more practical; if I were to switch the places of both of those while routines, would it make any difference in the way the code is read and executed?