4 votes 4 votes void main() { int x,y; y=10; scanf("%d", &x); } When memory wil be allocated to the x and y?Compile time or run time? Programming in C programming-in-c + – rahul sharma 5 asked Sep 23, 2017 rahul sharma 5 602 views answer comment Share Follow See all 11 Comments See all 11 11 Comments reply Show 8 previous comments Manu Thakur commented Sep 23, 2017 i edited Sep 23, 2017 reply Follow Share @joshi memory for an array will be allocated at compile time, isn't it? 0 votes 0 votes joshi_nitish commented Sep 24, 2017 reply Follow Share here array is also local variable, then why memory will be given to it at compile time. 0 votes 0 votes Arjun commented Sep 24, 2017 reply Follow Share @Joshi Yes, by definition "allocation" means setting aside of memory. And this happens at compile time for all static memory allocation -- which includes stack in C. But the actual memory being created for stack -- not called allocation -- is at runtime. For example, at compile time we can know how much memory a function stack takes. But only during runtime, we can know how many times, that stack is being used by the function like during a recursive call. So, for this exact question answer would be x and y are allocated memory during compile time on stack and hence not initialized. 1 votes 1 votes Please log in or register to add a comment.