Thank you Guys for your time and infomration !!
Actually I was calling
form.submit()
in java script apart from
<from name=frm method=post action=x.phtml >
In effect It was calling the same phtml two times which
is calling my "C" program two times.
I deleted form.submit() and it started executing my "C" program
only once.
-PK