I just completed my first semester of c++ class, and I'm going back and redoing my midterm for shits and giggles (can't sleep).
Well, I'm a bit stuck. The midterm had us use the <cmath> pow operator to take a radius and square it...however I am having some issues using an array / for loop to iterate and work; here's my code: (considerably snipped, just to illustrate the parts that I'm confused about)
const int arrayset=3;
int total,
i=0,
g[arrayset], // Radius
a[arrayset]; // Area
double pi=3.1415;
----- Later
for (i=0; i<arrayset; i++){
a[i]= pi*(pow(g[i],2)); // This line is the problem line!
}
By my logic the line reads as follows:
a[x] = pi times g[x] raised to the second power. The error I'm getting is that I overloaded the operator... which seems a little off.
I have found a (much less desirable) workaround, I can simply use a[i]= pi*(g[i]*g[i]); but that just doesn't feel like I'm doing the right thing.