Print list of value using only i/o and while

Greetings all,
I'm new to c++,
I learn from a book,
Just learn input/output, comment and while statement,
An exercise there ask me to write a program that prompts for two integers and print each number in the range specified by those two integers.
I write down codes but I am not sure it's right as if the first integer is bigger than the second, it failed.
Is it posible to list down all the numbers using only what I've learnt?

1
2
3
4
5
6
7
  int va, vb, v;
  cout << "input value a and value b: " << endl;
  cin >> va >> vb;
  while (va <= va) {
  v = va;
  cout << "value a: " << v << endl;
  ++va;
I am not sure it's right as if the first integer is bigger than the second, it failed.
I would say it should do that, but you should reread your exercise and find out what it wants you to do in this case.

while (va <= va) { I think you meant vb here.

1
2
3
  v = va;
  cout << "value a: " << v << endl;
  ++va;
You do not need intermediate variable. Just
1
2
cout << "value a: " << va << endl;
++va;
or even cout << "value a: " << va++ << endl;
Thank you so much @MiiNiPaa for the help, it really gave me new insight..

I've reread the question and it doesn't declare clearly (or maybe I was assuming too much),
So, I'll consider it's done..

It just picks my curiousity on how to print the value list in case the first integer is bigger than the second, is it possible just using input, output and while?
After you read in the numbers, use an if statement to check if the first int is bigger than the second. If this is the case, you could then either swap the variables, or assign the given values to new variables that you use in the loop.
Thank you @freddy92 for the idea,
I got it now..
Topic archived. No new replies allowed.