Thanks for your response. I replaced all the Serial.print() for strings with F(). Now F() thing does not work with Serial.printf. There is a function printf_P, that takes 1st arg as a pgmspace string. So I wrote a macro as follows:
#define DEBUG_PRINTF_P(x,...) printf_P(PSTR(x),__VA_ARGS__)
Then in the code I wrote:
int i=100;
DEBUG_PRINTF_P("value of i is: %d", i);
It prints:
value of i is: 1073692176
Can you tell me where I am going wrong?