Or it might be a problem elsewhere?
I am doing an exercise from a recommended book, in which I am trying to get the program to print all numbers from n1 to n2 .
Here is what I have come up with:
Instead of getting the increments, it simply adds 1 to n2. I have looked for an example on the accompanying CD (that came with the book), but it doesn't have a sample for the exercise.Code:#include <iostream> using namespace std; int main() { int n1, n2, i; cout << "Please enter a number: "; cin >> n1; cin.ignore(); cout << "Please enter a higher number: "; cin >> n2; cin.ignore(); for (i = n1 ; i <= n2; i++); cout << i << " "; cin.get(); return 0; }
Where did I go wrong?



LinkBack URL
About LinkBacks


