atleast what i have done is correct or not.
is that code can be done in much shorter way.....