is it possible to use 8051 microcontroller as input as well as output at a time? if i use particular pin as input and then how to make it as output as well.tell me please i born just now in microcontroller
The original 8051 and 80C51 has so-called pseudo-bidirectional I/O pins- they are open drain, with internal pullups (some pins may require external pullup resistors). So, they don't have (or need) the direction registers you may be familiar with from more modern microcontroller families than the rather long-in-the-tooth MCS-51).
So to use a pin as an input you write a '1' to the particular bit and read the pin. Whatever is connected to the 'input' must be able to sink more current than the pullup delivers.
It is not possible to use a pin as an input if it is set to '0' (the pull down transistor is quite strong).
The source current capability of the pin when used as an output is limited to what the pullup can deliver (though there is a 'strong' source transistor that comes on briefly when the pin is switched from '0' to '1' in order to charge stray capacitance connected to the pin quickly.
Edit: The above is a simplified view that was added know my answer, I will leave it as it may be useful, but for a more complete view, check this more recent answer.
The older style 8051 microcontroller ports are not the same as other more modern microcontrollers which can often have mixed inputs and outputs on the same port. If I recall correctly the standard 8051 must have all pins of the same port either used as all inputs or all outputs, at any one time.