Help with variables
Ok, so this is my problem:
Now, using
[EDIT:] I decided to go a simpler route and just used arrays. My final code is as follows:
double dec1 = 5.76;
string varDecName = "dec1";Now, using
varDecName, how can I access the 5.76 for use in calculations?[EDIT:] I decided to go a simpler route and just used arrays. My final code is as follows:
#define COUNT 5
double decimal[COUNT];
double intAverage;
int integer[COUNT];
int iIndex, intSum;
cout << "Please enter " << COUNT << " positive decimal numbers." << endl;
for (i=0; i<COUNT; i)
{
cout << i << ": ";
cin >> decimal[i];
}
for (iIndex=0; iIndex<COUNT; iIndex)
{
integer[iIndex] = static_cast<int>(decimal[iIndex] +0.5);
} 