C | Misc | Question 8

Output of Below C Code? Assume that int takes 4 bytes.

filter_none

edit
close

play_arrow

link
brightness_4
code

#include<stdio.h>
int x = 5;
int main()
{
    int arr[x];
    static int x = 0;
    x = sizeof(arr);
    printf("%d", x<<2);
    return 0;
}

chevron_right


Thanks to Gokul Kumar for contributing this question.
(A) Compiler error in line “static int x = 0”
(B) 7
(C) 80
(D) 20


Answer: (C)

Explanation: Size of gives size of arr * int in bytes = 20
Left shift two times gives you 80.

Quiz of this Question

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.