do these changes in your code
=========================
Code:
...............
char ans[2];    
.............
if (ans[0]=='y')....
...........