Help with adding a list of variables, maybe a loop?

So I've got something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>

using namespace std;

int main()
{
    int currentparagon;
    int desiredparagon;
    int paragonxp;
    int paragon1;
    int paragon2;
    int paragon3;
    int paragon4;
    int paragon5;
    int paragon6;
    int paragon7;
    int paragon8;
    int paragon9;
    int paragon10;


    cout << "What is your cureenr paragon level?" << endl;
    cin>> currentparagon; //Gets current paragon
    cin.ignore(); // ignores the enter key
    cout << "What is your desired paragon level?";
    cin>> desiredparagon;
    cin.ignore();
    return 0;
}


Except my paragon variables will go to 100. I am going to put values for each variable in later, I just need to somehow make something that will add a range of these variables, as the user specifies. So if he says his current level is 4 and his desired level is 9, I want it to do a math problem like : paragon4 + paragon5 + paragon6 + paragon7 + paragon8 + paragon9.

Of course, you could type this in with a bunch of else if functions, but with 1 hundred variables that would take forever. Please help
Generally, when you have variables like x1, x2, x3,... you should turn them into an array.
Topic archived. No new replies allowed.