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() { int i, j; scanf("%d %d"+scanf("%d %d", &i, &j)); printf("%d %d", i, j); } a. Runtime error. b. 0, 0 c. Compile error d. the first two values entered by the user

2 Answers   HCL,


main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); }

1 Answers  


main() { int x=5; for(;x!=0;x--) { printf("x=%d\n", x--); } } a. 5, 4, 3, 2,1 b. 4, 3, 2, 1, 0 c. 5, 3, 1 d. none of the above

2 Answers   HCL,


What is the subtle error in the following code segment? void fun(int n, int arr[]) { int *p=0; int i=0; while(i++<n) p = &arr[i]; *p = 0; }

1 Answers  


#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

1 Answers  






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.

9 Answers   Microsoft,


Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange

0 Answers  


how can i search an element in an array

2 Answers   CTS, Microsoft, ViPrak,


To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates.

19 Answers   Amazon, BITS, Microsoft, Syncfusion, Synergy, Vector,


Write a program that reads a dynamic array of 40 integers and displays only even integers

2 Answers  


How do you create a really large matrix (i.e. 3500x3500) in C without having the program crash? I can only reach up to 2500. It must have something to do with lack of memory. Please help!

1 Answers  


Declare an array of N pointers to functions returning pointers to functions returning pointers to characters?

1 Answers  


Categories