0 votes 0 votes #include<stdio.h> void temp(int a[]); main(){ int a[5]={1,2,3,4,5}; printf("%d", sizeof(a)); temp(a); } void temp(int a[]){ printf(" %d", sizeof(a)); } Output of above code is, given size of int is 4 byte $20$ $20$ $20$ $8$ $8$ $8$ $8$ $20$ Programming in C programming-in-c + – hacker16 asked Apr 5, 2018 edited Apr 7, 2018 by Subarna Das hacker16 503 views answer comment Share Follow See all 5 Comments See all 5 5 Comments reply gauravkc commented Apr 5, 2018 reply Follow Share 20 and Size of pointer depends on machine. 4 for 32 bit and 8 for 64 bit. So, 20 8 1 votes 1 votes Prashant. commented Apr 5, 2018 i edited by Prashant. Apr 5, 2018 reply Follow Share B will be answer 0 votes 0 votes Mk Utkarsh commented Apr 5, 2018 reply Follow Share 20 4 0 votes 0 votes anonymous commented Apr 5, 2018 reply Follow Share the array is passed as the pointer, so the size of the pointer will be printed. 0 votes 0 votes kd..... commented Apr 23, 2018 reply Follow Share machine dependent 0 votes 0 votes Please log in or register to add a comment.
Best answer 2 votes 2 votes In main() printf("%d" , sizeof(a)) gives size of the array i.e number of elements * size of the element = 5*4 = 20bytes When the array is passed as the parameter, it is treated as a pointer.So the sizeof(a) in the function will give the size of the pointer either 4 or 8 depending on the machine. pankaj_vir answered Apr 5, 2018 selected Apr 12, 2018 by rio pankaj_vir comment Share Follow See all 0 reply Please log in or register to add a comment.