Help Analyzing Simple Code

Could Someone Please Explain How 3 is the answer?

#include <iostream>
#include <string>
using namespace std;
int main()
{
int ctr = 0;
int myarray[4];
for( int i = 0; i < 4; i++)
{

myarray[i] = ctr;
ctr = ctr+ i;

}
cout<< myarray[3];
}
Topic archived. No new replies allowed.