I want to read username and password from web.config file.
Username,password will be stored in custom tags of web.config file of sharepoint project.
Ouch - don't do this! Use the Secure Store Service to map user credentials. It is designed to store and map credentials in a very secure way.
its simple, check this out on msdn it explains it really simply:
but this shouldnt store a user ID/Password ;) that should be kept in AD(active Directory)
if its for a webpart to connect like to K2 server or SQL then its fine:
reading connection string: http://msdn.microsoft.com/en-us/library/ms178411
Read app settings from web.config http://msdn.microsoft.com/en-us/library/610xe886.aspx