It's been more than 12 hours that I've started working with this small program. Yes, I just now got to know my mistake!
There is nothing wrong with the code but the order of statements. The below code generates what I wanted:
Insert statements should come after trigger.
Thanks for your replies!