Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,196 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,342 people online right now. Registration is fast and FREE... Join Now!




Arrays

 
Reply to this topicStart new topic

Arrays, Need Help with C-programming homework

!!!
21 May, 2008 - 11:10 PM
Post #1

New D.I.C Head
*

Joined: 14 May, 2008
Posts: 3

I got my quiz back, which is about arrays, from my computer programming class, but there's a problem I got wrong. I don't want to ask my professor for help because he's a boring but moody lecturer who can't teach.

Given the following function prototypes:
CODE
void DoThis (float[][9]);
int iGetIt (float);
"Using integer variable iKnow, write the statement that would appear in main() that calls iGetIt(), dpassing it the single array element of the afPrice array that is in the upper left hand corner of the matrix:"
This is what I wrote down as my answer:
CODE
iGetIt (afPrice[0][0]);
return (iKnow);
iKnow = iGetIt(afPrice[0][0]);

I got the last line, iKnow = iGetIt(afPrice[0][0]);, incorrect. Can anyone explain why, what is the correct answer, and how can I obtain it?

This post has been edited by !!!: 21 May, 2008 - 11:32 PM
User is offlineProfile CardPM
+Quote Post

gabehabe
RE: Arrays
22 May, 2008 - 05:04 AM
Post #2

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,556



Thanked: 99 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
(afPrice[0][0]) sends one value to the function, which is in position 0,0. In order to send an entire array, you would need to pass a pointer to it's address, in order to send all values stored in the array.

Hope this helps smile.gif

This post has been edited by gabehabe: 22 May, 2008 - 05:04 AM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 12:11PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month