# Help Needed On Take-Home C++ Final Exam



## dcf-joe (Dec 15, 2009)

I have already answered 46 out of 50 of the questions, and I just need some guidance on 4 of the questions.

Which of the following function declaration is correct?
int f(int[][] a, int rowSize, int columnSize);
int f(int a[3][], int rowSize;
int f(int a[3][], int rowSize;
int f(int a[3][], int rowSize;
int f(int a[][3], int rowSize;
int f(int a[][], int rowSize, int columnSize);

What is the correct term for numbers[99]?
index
index variable
array variable
indexed variable
array  /* I believe this one is the answer */

Which of the following is incorrect? (There is more than one answer)
int a[2];
int a = new int[2]; /* I know this one is wrong because it should be int *a = ... */
int a() = new int[2]; /* This one does not even look right */
int a(2); /* This might be "incorrect," but it could be calling a function */
int a[];

Which of the following statements are true? (There is more than one answer)
Every element in an array has the same type. /* False, because I have used different types before and it works */
Array size must be declared by a constant expression. /* The book makes this statement verbatim */
The array elements are initialized when an array is created. /* Need help here */
The array size is fixed after it is created. /* Need help here */


----------



## temp02 (Dec 15, 2009)

Which of the following function declaration is correct?
int f(int a[][], int rowSize, int columnSize);​
What is the correct term for numbers[99]?
array _<although the way the question was made was not the best IMHO>_​
Which of the following is incorrect? (There is more than one answer)
int a[2];​int a[];​
Which of the following statements are true? (There is more than one answer)
Every element in an array has the same type. *True* _<this really is true by definition, you must be thinking of a class list>_​Array size must be declared by a constant expression. *True* _<again like the other question above this is not the best way to ask this, depending on the context, but technically it's true>_​The array elements are initialized when an array is created. *False*​The array size is fixed after it is created. *True*​
​
The answers were done based on the fact that we are talking about "true" arrays, not vectors nor dynamically allocated arrays.

Hope this helps.


----------



## Kreij (Dec 15, 2009)

Which of the following is incorrect? (There is more than one answer)
int a[2]; *Correct*
int a = new int[2]; *You are right, the new keyword returns a pointer*
int a() = new int[2]; *no*
int a(2); *Why would anyone delare a funtion with a constant parameter? I don't think so.*
int a[]; *You would have to do this with pointers and dynamic arrays ... no*


Disclaimer : I could be wrong. lol


----------



## dcf-joe (Dec 15, 2009)

Thanks ALL


----------



## Kreij (Dec 15, 2009)

Let us know know you do on the test !! 

... and, of course, come back for more help anytime.


----------



## dcf-joe (Dec 17, 2009)

My teacher has not emailed me back with my final exam score, but I did make a B for the overall class period. Even though I very much wanted an A, I guess I did not work hard enough. But, I did learn a lot!!!

I would like to sincerely thank Kreij and temp02 for assisting me with those four questions.


----------



## Kreij (Dec 18, 2009)

You're welcome dcf-joe, always a pleasure to help.
You know where to find us when you get stuck again.


----------



## C4rnage (Dec 18, 2009)

The array size is fixed after it is created.

not sure about C++, but on C, you could realloc a array increasing its size. the commands were calloc and malloc, i dont remember the diference, but i think one, it will realloc and set 0.


----------



## Kreij (Dec 18, 2009)

You are right C4r, and welcome to TPU


----------

