here I have problem. I need the code for creating an answering machine for the landline phone wherein it automatically connects to voice module immediately after 3 rings.

Can you provide any more details? Or were you actually expecting useful help from that vague description?

it is like when the phone rings,the answering machine should answer the call automaticatically from the system using the modem. i actually don't know the basics for this topic. the answering machine should show the caller id and number from the database. also the answering machine should reply the caller. is it possible? if it is i just want to know the procedure

it is like when the phone rings,the answering machine should answer the call automaticatically from the system using the modem.

Yes, that's obvious. What's not obvious is whether this is a simulation or you're actually programming for hardware. If this is a simulation then it constitutes homework, and I'll direct you to our rules about proof of effort. If this is an actual answering machine then your first line of attack is learning how to interface with the hardware (ie. reading the documentation).

You need to read about AT commands and how to listen to a comm port.

Good luck with that.