what i am trying to do with this code is just to get it to count from 1 number the user inputs to a second number they input and count from one to the other but it only works if the first number is less then the second any tips?
yes i do realize this is a pretty boring program with no real application but its a learning process
Code:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
int i , n1, n2;
cout<< " enter a number and press enter: ";
cin>> n1;
cout<< "enter another number and press enter: ";
cin>> n2;
i = n1;
if(n1 < n2){
while (i <= n2) {
cout<< i <<' ';
i = i + 1;
}
}
else{
while (i <= n2) {
cout<< i << ' ';
i = i - 1;
}
}
system("PAUSE");
return 0;
}