with fflush(stdin) & two getchar()'s it has started working.. thanks a ton horace..
You shouldn't fflush stdin, it is undefined behaviour and thus very bad.
It is in fact undefined behaviour to fflush any input stream or update (read/write) stream whose most recent operation is a read.
Here is the appropriate section of the C standard
int fflush(FILE *ostream);
ostream points to an output stream or an update stream in which the
most recent operation was not input, the fflush function causes any
unwritten data for that stream to be delivered to the host environment to
be written to the file; otherwise, the behavior is undefined.