Hi,
it's working now.I don't understand why it was showing segmentation fault earlier but,it's working fine for now.