A segmentation fault occuring please explain the reason

@guptanikhil898,
Because you are accessing out of bound index in prime_sieve function(i=10005), and also, in checkandprint before accessing s.top() you aren’t checking whether its empty or not.