3 votes 3 votes Answer of this question is given as (C), but I am not able to get it how. Can any1 please explain this? Programming in C ace-test-series data-structures programming-in-c + – Asim Abbas asked Jan 11, 2018 retagged Mar 6, 2019 by Rishi yadav Asim Abbas 436 views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply Mk Utkarsh commented Jan 11, 2018 reply Follow Share segmentation fault is there because in the code we are directly assigning int value to a pointer. rather we should allocate some int memory using malloc. it should be main(){ void *memory = malloc(sizeof(int)); int *k = (int *)memory; *k = m(); } and segmentation fault happens when program tries to access the address and is not able to find one hence in the question printf is trying to access address of *k but is not able to find one 1 votes 1 votes hacker16 commented Jan 13, 2018 reply Follow Share function m() returning location of array a[ ], but once the calling of m() have been finished, the array a[ ] is going to be dead (scope is going to be end) and it refer to dangling reference. this dangling reference might lead to segmentation fault. 2 votes 2 votes Please log in or register to add a comment.