C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - Yes / No Questions (Q.No. 1)
Is there any difference in the following declarations?
int myfun(int arr[]);
int myfun(arr[20]);
Answer: Option
Yes, we have to specify the data type of the parameter when declaring a function.
11 comments Page 1 of 2.

Kruthika said:   3 years ago
@Venkat, Thanks.

Venkat said:   5 years ago
Yes, there difference that is;

int myfun(int arr[]);>>>>in this declaration we restrict the compiler you should take parameter as a INT, otherwise send the error.

int myfun(arr[20]);>>>>in this we are not restrict the compiler, compiler choice it is take parameter as any data type.

DANIEL said:   5 years ago
In C the default return type of a function parameter is int, so the answer for the above statement must be NO.

Anil T said:   7 years ago

Yes, in case of first, it can accept array of length 1 or more than 1 while in case of second it can accept only array of maximum length 2.

Juhi said:   8 years ago
Is there any difference in the following declarations?

int fun(int arr[]);
int fun(int arr[2]);

Hemlata said:   9 years ago
When no data type is declared in arguments passing to function it is taken as int by default so these should be same?

Karvendan.A.P said:   1 decade ago
Can you please tell me exact difference between * and [ ] while passing as an argument like

void my_stringlength(char []);
void my_stringlength(char *);

Kasak said:   1 decade ago
First statement is correct
Second statement is incorrect because there is no declaration of data type such as whether is it int, char or double etc?

Ankita said:   1 decade ago
Can you please explain in which statement data type of parameter is specified and which is the corret statement ?

Bhaskar said:   1 decade ago
First one is Function Declaration that is declared at top of main. So in function declaration we need to specify the type of parameter we are going to pass as actual parameter. Next one is Function calling.

Post your comments here:

Your comments will be displayed after verification.