Originally Posted by
cherryteresa
You're right, I was thinking about how all this math ties together. It's crazy to think about sometimes!
Okay, so thank you for pointing out the power thing. I think this is where I got stuck before. I'm trying to figure out how to raise something to the power. We didn't go over this in class and all the things I could find online showed it in printf form and not cout. And so I'm having trouble figuring out how to do it. I think basically what I need to do is:
for (int x=0; x<size; x++)
{
sum += pow (2, x); - // trying to figure
// out how to
//translate this to code.
// 2 to the x power
for (int y=0; y<size; y++)
{
}
cout<<sum<<"\n"<<endl;
}
}
I'm going to keep searching.
pow (int, int) doesn't exist.
http://www.cplusplus.com/reference/c...cmath/pow.html
Make one or both a double:
pow (2.0, x); // or pow (2.0, (double) x);
pow is from cmath, which you have as math.h. You may want to change those #include statements to include C++ libraries (cstdlib, cctype, cmath, cstdio) rather than the .h files. I'm not sure whether the compiler cares or not (probably not), but at least it makes clear that you are using C++ to the reader.