Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Write a function to find the number of elements in an integer array.
Write a function to find the number of elements in an integer array.
# include & ltstdio.h & gt

int size (int a[])

{

return sizeof(a)/4;

}

int main()

{

int sz

int aa[]={346,45,7,235,4,68,23,457,235,468,235,6823,556,568,23}

Unsigned short integer bb[]={346, 45, 7, 235, 4, 68, 23, 457, 235, 468, 235, 6823, 556, 568, 23};

Unsigned long integer cc[]={346, 45, 7, 235, 4, 68, 23, 457, 235, 468, 235, 6823, 556, 568, 23};

short int dd[]={346,45,7,235,4,68,23,457,235,468,235,6823,556,568,23 };

SZ = sizeof(aa)/4; //directly feasible.

Printf ("number of elements of aa: %d\n", SZ);

SZ = sizeof(bb)/2;

Printf ("number of elements in bb: %d\n", SZ);

SZ = sizeof(cc)/4;

Printf ("Number of elements in CC: %d\n", SZ);

SZ = sizeof(DD)/2;

Printf ("Number of elements of DD: %d\n", SZ);

Sz = size (aa); //The function method is not feasible.

Printf ("number of elements of aa: %d\n", SZ); //The transfer function should be: fun( int a[], int arry).

Returns 0;

}