C Programming - Pointers - Discussion

Discussion Forum : Pointers - Find Output of Program (Q.No. 23)
23.
If the size of integer is 4bytes, What will be the output of the program?
#include<stdio.h>

int main()
{
    int arr[] = {12, 13, 14, 15, 16};
    printf("%d, %d, %d\n", sizeof(arr), sizeof(*arr), sizeof(arr[0]));
    return 0;
}
10, 2, 4
20, 4, 4
16, 2, 2
20, 2, 2
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
22 comments Page 3 of 3.

N prathyusha said:   2 decades ago
The array elements are 5 each of size 4 bytes so it is 20.
Where as second is size of addres not the individual element so the size of int as declared is 4 so it is 4.
Then the final one is size of individual element i.e. size of first array element so it is 4.

PRADEEP said:   2 decades ago
Thank you.


Post your comments here:

Your comments will be displayed after verification.