int main() {
int n1, n2;
int i=n1;
cout << "Enter 2 numbers "<< endl;
cin >> n1, n2;
while (i<=n2){
cout << i << endl;
i = i+1;
}
return 0;
}
I can't get this to print the numbers between n1 and n2
Both of you, use [code][/code] to highlight the code!
Now the errors.
Firstly, the position of i = n1 is wrong, it will come after you take the value of n1.
Move it after the cin Line. Then set the value of i. Right now it is setting some garbage value to i since n1 has no value assigned to it.
Also when you want to take in more than one input with cin, you do it just as you output something with cout. By using >> for every variable whose value you want...
One question for you regardin your problem:
What if I input n1 as 10 and n2 as 3?