Saturday, July 7, 2007

Interesting C Program -5

Guess the output of the following C program!!!
If your guess is 40, it is definitely not!!!

#define SIZE 10
void size(int arr[SIZE])
{
printf("size of array is:%d\n",sizeof(arr));
}
int main()
{
int arr[SIZE];
size(arr);
return 0;
}

Explanation:
The input to the function is not the entire array. Only the address of the first element of the array will be passed into the function.

No comments:

Search Google

Books that I refer to...

  • The Complete Reference C, Fourth Edition
  • The C Programming Language