C Programming - Arrays - Discussion

Discussion Forum : Arrays - Point Out Correct Statements (Q.No. 1)
1.
Which of the following is correct way to define the function fun() in the below program?
#include<stdio.h>

int main()
{
    int a[3][4];
    fun(a);
    return 0;
}
void fun(int p[][4])
{
}
void fun(int *p[4])
{
}
void fun(int *p[][4])
{
}
void fun(int *p[3][4])
{
}
Answer: Option
Explanation:

void fun(int p[][4]){ } is the correct way to write the function fun(). while the others are considered only the function fun() is called by using call by reference.

Discussion:
14 comments Page 2 of 2.

OMKAR GURAV said:   10 years ago
Why it cannot be call by reference function and option C be the answer?

Saisiva said:   1 decade ago
How the function fun(a) implies fun(int p[][4])?

Sravan.rkv said:   1 decade ago
Thank you sai narendra my doubt is cleared.

Sai narendra said:   1 decade ago
Hi, when we use *in front of the formal perameters (those perameters are in called function) it represents function is called by reference. That means the change of the values of the variables is perminant.


Post your comments here:

Your comments will be displayed after verification.