int DIM(int array[])

{

return sizeof(array)/sizeof(int );

}

main()

{

int arr[10];

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..

Answer / susie

Answer :

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 ?    9 Yes 2 No

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

Answer / manoj kumar

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

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More C Code Interview Questions

#define int char main() { int i=65; printf("sizeof(i)=%d",sizeof(i)); }

1 Answers  


#if something == 0 int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }

1 Answers  


main() { show(); } void show() { printf("I'm the greatest"); }

2 Answers  


main() { char *p = “ayqm”; printf(“%c”,++*(p++)); }

29 Answers   IBM, TCS, UGC NET, Wipro,


why array index always strats wuth zero?

2 Answers  






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

1 Answers  


#define max 5 #define int arr1[max] main() { typedef char arr2[max]; arr1 list={0,1,2,3,4}; arr2 name="name"; printf("%d %s",list[0],name); }

1 Answers  


posted by surbhi just now main() { float a = 5.375; char *p; int i; p=(char*)&a; for(i=0;i<=3;i++) printf("%02x",(unsigned char) p[i]); } how is the output of this program is :: 0000ac40 please let me know y this output has come

2 Answers   GATE,


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.

2 Answers   Wipro,


main() { int i=10,j=20; j = i, j?(i,j)?i:j:j; printf("%d %d",i,j); }

2 Answers   Adobe, CSC,


C statement to copy a string without using loop and library function..

2 Answers   Persistent, TCS,


main() { int a=10,*j; void *k; j=k=&a; j++; k++; printf("\n %u %u ",j,k); }

1 Answers  


Categories