Creating series of outputs using a array created by a variable?

Hey guys/gals,

I'm somewhat new to C++, and I've got an assignment for school that i'm having some trouble with.

I'm expected to get a starting minimum input, and also an ending maximum output (for example: 21, and 25). From here, i have to give output using all the numbers (in a row) between the min and max numbers.
(for the same example:
21
22
23
24
25)
I assumed I would want to create an array using a variable, but i'm not sure of that either. Anyone care to help a newbie? :)
this?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int min;
    int max;
    cout << "please enter max: ";
    cin >> max;
    cout << "\n please enter min: ";
    cin >> min;
    for (int i = min; i < max+1; i++) {
        cout << i << endl;
    }
    return 0;
}


no need for an array.
Last edited on
Thanks a ton! but how do you use the defined series? i.e. How do you use the 'i' variable to create the output of each number?

My knowledge is really basic; I am really grateful for the help.
I'm sorry, i probably wasn't descriptive enough. How do I use each integer in a specific output (example: min 5, max 10; how do i create
one number is 5
one number is 6
one number is 7
one number is 8
one number is 9
one number is 10)

This was my main concern. Thanks a boatload for the help!
O.K., I figured my dilemma out by myself; I feel bad for my really amateur questions. I have just one more question for adding an 'if' statement in the 'for' statement --
(example: min = 16, max =25. When there is a number declared higher than 21 --
Before the rest of the numbers above 21 are stated, there is a 'cout' saying "these are numbers beyond 21")

I.E -
16
17
18
19
20
these numbers are beyond 21
21
22
23
24
25

Topic archived. No new replies allowed.