How do I create a block that has links to site registration and forgot password programmatically? Can anyone help me writing code for a block containing the "Register" and "Forgot your password?" links that are shown to the anonymous users?
If you want to learn, I suggest, look at the relevant part of drupal core:
user_block_info() - this is the block info definition.

user_block_view() - This builds the renderable array of block.

You see here $block['content'] = drupal_get_form('user_login_block'); This makes the complete user login form. If you want to show only the two link, just change this to something like this:

$block['content'] = array(
  '#markup' =&gt; 'the pure html of your links',
);


To check, how to generate the core these links, see the user_login_block() in core. The line 1323 is the html markup in you block's content, what do you need