The following is a sample program out of my book. The program's description is lousy and I cannot figure out what exactly how it works.. Could someone please help me understand it. I understand how for loops work, but this program has TWO for loops in it, and it's confusing..
Thanks
#include <iostream>
using namespace std;
const int ArSize = 16;
int main()
{
double factorials[ArSize];
factorials[1] = factorials[2] = 1.0;
int i;
for (i = 2; i < ArSize; i++)
factorials[i] = i * factorials[i-1];
for (i = 0; i < ArSize; i++)
cout << i << " ! = " << factorials[i] << "\n";
That makes sense! I can't believe that's all it took to get me to understand it.
I don't know what I would do with this C Plus Plus Forum, it has helped me get past many walls. There aren't any classes at community colleges around here that offers classes on C++, so I got a text book and have been trying to teach myself..