Define an int array variable named arx with 3 slots, and stuff a 7 in the last slot

int arx[2]=7;
or is it:
int arx[3];
arx[2]=7;

Is this correct?

Define an int array variable named arx with 3 slots, and stuff a 7 in the last slot
Is this correct?

int arx[2]=7; // NO //

or is it:

// int arx[3]; // this has 3 slots
// or better ... initial all to 0 at creation ...
int arx[3] = { 0 };
// then can update last slot ... (recall: C/C++ arrays start with index 0)
arx[2] = 7;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.