• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Help Needed On Take-Home C++ Final Exam

Joined
Feb 11, 2008
Messages
607 (0.10/day)
Location
Omaha, Nebraska, USA
System Name Built By Me
Processor Intel Core i9 9900K @ 5.1 GHz
Motherboard Gigabyte Z390 Aorus Ultra
Cooling Custom Water Cooling - CPU Only
Memory 32GB (2 x 16) GSkill Ripjaws V DDR4
Video Card(s) RTX 4080 - ASUS ROG Strix 16GB OC - P Mode
Storage 1TB Samsung 970 Evo NVMe
Display(s) Alienware AW2723DF @ 280 Hz @ 1440P
Case Fractal Design Define S2
Audio Device(s) Corsair Virtuoso Pro
Power Supply 850W Seasonic Platinum
Mouse Razer Viper V2 Pro @ 2k Hz
Keyboard Asus ROG Strix Scope II 96 Wireless - ROG NX Snow Switches
Software Windows 11 Pro
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

New Member
Joined
Mar 18, 2009
Messages
493 (0.09/day)
  • 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

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
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
 
Joined
Feb 11, 2008
Messages
607 (0.10/day)
Location
Omaha, Nebraska, USA
System Name Built By Me
Processor Intel Core i9 9900K @ 5.1 GHz
Motherboard Gigabyte Z390 Aorus Ultra
Cooling Custom Water Cooling - CPU Only
Memory 32GB (2 x 16) GSkill Ripjaws V DDR4
Video Card(s) RTX 4080 - ASUS ROG Strix 16GB OC - P Mode
Storage 1TB Samsung 970 Evo NVMe
Display(s) Alienware AW2723DF @ 280 Hz @ 1440P
Case Fractal Design Define S2
Audio Device(s) Corsair Virtuoso Pro
Power Supply 850W Seasonic Platinum
Mouse Razer Viper V2 Pro @ 2k Hz
Keyboard Asus ROG Strix Scope II 96 Wireless - ROG NX Snow Switches
Software Windows 11 Pro

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
Let us know know you do on the test !! :toast:

... and, of course, come back for more help anytime.
 
Joined
Feb 11, 2008
Messages
607 (0.10/day)
Location
Omaha, Nebraska, USA
System Name Built By Me
Processor Intel Core i9 9900K @ 5.1 GHz
Motherboard Gigabyte Z390 Aorus Ultra
Cooling Custom Water Cooling - CPU Only
Memory 32GB (2 x 16) GSkill Ripjaws V DDR4
Video Card(s) RTX 4080 - ASUS ROG Strix 16GB OC - P Mode
Storage 1TB Samsung 970 Evo NVMe
Display(s) Alienware AW2723DF @ 280 Hz @ 1440P
Case Fractal Design Define S2
Audio Device(s) Corsair Virtuoso Pro
Power Supply 850W Seasonic Platinum
Mouse Razer Viper V2 Pro @ 2k Hz
Keyboard Asus ROG Strix Scope II 96 Wireless - ROG NX Snow Switches
Software Windows 11 Pro
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

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
You're welcome dcf-joe, always a pleasure to help.
You know where to find us when you get stuck again.
 

C4rnage

New Member
Joined
Dec 18, 2009
Messages
14 (0.00/day)
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

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (2.20/day)
Location
Cheeseland (Wisconsin, USA)
You are right C4r, and welcome to TPU :toast:
 
Top