if possible i need a method which can change the baud-rate (could be of anything)during during the execution of the program,. appreciate it, thanks.
Time to look here.
Serial.begin()
I haven't tried this, but I have seen auto-detect serial links. My guess is that they depend on a stream of known data from the other end, and progressively set different baud rates until the link begins to read the expected stream.
So try sending to the Arduino, say, a steady stream of 'A's, and try something like this, but better in a loop structure, of course.
Serial.begin(9600);
c = char(Serial.read());
if (c == 'A') ... you've found the rate
Serial.end();
Serial.begin(19200);
c = char(Serial.rtead());
if (c == 'A') ... etc.