Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (anonymous):

c programming array problem. Please help

OpenStudy (anonymous):

In c, an array needs to be declared with a size of some type. It can be explicit or implicit, but there needs to be a way for the compiler to determine how much memory to allocate for the array. Which of those answers doesn't have enough information to infer a size?

OpenStudy (anonymous):

The answer lies in which array declaration (int sutdent[number]) doesnt equal the number of places trying to be input

OpenStudy (anonymous):

@dave0616 you may also learn from this question: Try compiling this code and looking at which causes the error. int main(void){ int studentIDa[] = {11245, 11509, 12013, 11314}; int studentIDb[]; int studentIDc[4] = {11245, 11509, 12013, 11314}; int studentIDd[5] = {11245, 11509, 12013, 11314}; return 0; }

OpenStudy (anonymous):

Thats right, i am mistaken in my answer

OpenStudy (anonymous):

correct

OpenStudy (anonymous):

When you call a function, the parameter types (and the return type) have to match completely at the function declaration and the call site. For the first question, you've got floats and a float array. Your function only has floats in the declaration. So, which of those parameters isn't a float? In the second question, you're calling a function with two integers and it returns a float. Which answers do you think are correct?

OpenStudy (anonymous):

correct, and the second?

OpenStudy (anonymous):

The third answer is correct. The second is a syntax error. The first declares that there is an int array with a length of 2, which is fine, except that you would need to put your two variables into an array for it to accept them. It makes far more sense to keep them in individual variables, though.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!