The default baud rate for HC-05 is 38400 bauds. I was trying to set it to 9800. For some reason, that was not accepted by HC-05.
Solution: I changed the line #define BAUDRATE 9600 to #define BAUDRATE 38400 This
#define BAUDRATE 9600
to
#define BAUDRATE 38400
This solved my problem.