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;
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.