int DIM(int array[])

{

return sizeof(array)/sizeof(int );

}

main()

{

int arr;

printf(“The dimension of the array is %d”, DIM(arr));

}

Answers were Sorted based on User's Feedback

int DIM(int array[]) { return sizeof(array)/sizeof(int ); } mai..

1

Explanation:

Arrays cannot be passed to functions as arguments and only
the pointers can be passed. So the argument is equivalent to
int * array (this is one of the very few places where [] and
* usage are equivalent). The return statement becomes,
sizeof(int *)/ sizeof(int) that happens to be equal in this
case.

 Is This Answer Correct ? 8 Yes 1 No

int DIM(int array[]) { return sizeof(array)/sizeof(int ); } mai..

Arrays cannot be passed to functions as arguments and only
the pointers can be passed.

 Is This Answer Correct ? 1 Yes 0 No

More C Code Interview Questions

how to print 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 using any loop(for or while) only once(only 1 loop) and maximum 2 variables using C.

could you please send the program code for multiplying sparse matrix in c????

What are segment and offset addresses?

void ( * abc( int, void ( *def) () ) ) ();

Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).

main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }

Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.

main(){ int a= 0;int b = 20;char x =1;char y =10; if(a,b,x,y) printf("hello"); }

main( ) { int a = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}}; printf(“%u %u %u %d \n”,a,*a,**a,***a); printf(“%u %u %u %d \n”,a+1,*a+1,**a+1,***a+1); }

char *someFun() { char *temp = “string constant"; return temp; } int main() { puts(someFun()); }

main() { char str1[] = {‘s’,’o’,’m’,’e’}; char str2[] = {‘s’,’o’,’m’,’e’,’\0’}; while (strcmp(str1,str2)) printf(“Strings are not equal\n”); }

how to return a multiple value from a function?

Categories
• C Code (422)
• C++ Code (127)
• VC++ Code (17)
• Java Code (84)
• Dot Net Code (114)
• Visual Basic Code (11)
• Programming Code AllOther (62)