Hi, I am new to arduino programming..Can anybody provide me with codes for motor rotation in forward and reverse direction with a delay of 2 secs in between.

Have a look at this tutorial and there are lots of similar tutorials around.

You need an H-bridge to change direction, and the easiest way is to use a chip like the 293 in that tutorial, or a 298. You provide speed control by Pulse Width Modulation on an Arduino pin which has PWM capability.

Thanks a lot, can you provide me with tutorials like these that have angular control of dc motors using inputs from 3 axis accelerometer sensors? I am trying to use a 3 axis accelerometer in parallel with a dc motor shaft and make the motor rotate from 0 to 45 degrees and after a delay of 2 secs from 45 to 0 degrees.

Quick answer to that one is "No".... you'll have to Google that, and perhaps pose a new question here.

make the motor rotate from 0 to 45 degrees

If that's what you want to do, you would be better off with a stepper motor, or a servo. Accurate positioning with a regular dc motor would require end stops to detect when the motor had rotated to the required angle.