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

# include <stdio.h> int one_d[]={1,2,3}; main() { int *ptr; ptr=one_d; ptr+=3; printf("%d",*ptr); }

1 Answers  


main() { int i =10, j = 20; clrscr(); printf("%d, %d, ", j-- , --i); printf("%d, %d ", j++ , ++i); } a. 20, 10, 20, 10 b. 20, 9, 20, 10 c. 20, 9, 19, 10 d. 19, 9, 20, 10

4 Answers   HCL,


why the range of an unsigned integer is double almost than the signed integer.

1 Answers  


main() { printf("%d, %d", sizeof('c'), sizeof(100)); } a. 2, 2 b. 2, 100 c. 4, 100 d. 4, 4

18 Answers   HCL, IBM, Infosys, LG Soft, Satyam,


How will you print % character? a. printf(“\%”) b. printf(“\\%”) c. printf(“%%”) d. printf(“\%%”)

4 Answers   HCL,






main() { int *j; { int i=10; j=&i; } printf("%d",*j); }

9 Answers   HCL, Wipro,


Program to find the largest sum of contiguous integers in the array. O(n)

11 Answers  


WAP to display 1,2,3,4,5........N

2 Answers  


Find your day from your DOB?

15 Answers   Accenture, Microsoft,


main() { if ((1||0) && (0||1)) { printf("OK I am done."); } else { printf("OK I am gone."); } } a. OK I am done b. OK I am gone c. compile error d. none of the above

5 Answers   HCL,


Develop a routine to reflect an object about an arbitrarily selected plane

0 Answers  


main() { int i = 0xff ; printf("\n%d", i<<2); } a. 4 b. 512 c. 1020 d. 1024

2 Answers   HCL,


Categories