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

main() { clrscr(); } clrscr();

2 Answers  


How to palindrom string in c language?

6 Answers   Google,


How to read a directory in a C program?

4 Answers  


void main() { int *mptr, *cptr; mptr = (int*)malloc(sizeof(int)); printf(“%d”,*mptr); int *cptr = (int*)calloc(sizeof(int),1); printf(“%d”,*cptr); }

1 Answers  


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

1 Answers  






main(int argc, char *argv[]) { (main && argc) ? main(argc-1, NULL) : return 0; } a. Runtime error. b. Compile error. Illegal syntax c. Gets into Infinite loop d. None of the above

4 Answers   HCL, LG,


writte a c-programm to display smill paces

2 Answers  


#define DIM( array, type) sizeof(array)/sizeof(type) main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr, int)); }

1 Answers  


main() { char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

2 Answers  


struct Foo { char *pName; char *pAddress; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); obj->pName = malloc(100); obj->pAddress = malloc(100); strcpy(obj->pName,"Your Name"); strcpy(obj->pAddress, "Your Address"); free(obj); printf("%s", obj->pName); printf("%s", obj->pAddress); } a. Your Name, Your Address b. Your Address, Your Address c. Your Name Your Name d. None of the above

2 Answers   HCL,


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,


int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().

1 Answers  


Categories