I see "printf" instruction in sample codes of c language for microcontroller particularly in 8051. Since microcontrollers has no fixed output display what is the use of the "printf" instruction?
More likely than not, so you can attach a debugging console, either through an RS232 port, or as virtual output from an in-circuit emulator.
printf is defined to output to stdout not an "output display", stdout may be any stream device. Typically on a system without a display it will output to a serial interface (UART), so that a terminal or terminal emulator (HyperTerminal or TeraTerm for example) may be used as a display device.
Some development environments implement "semi-hosting" where stdio, stdin, and stderr, and even in some cases a filesystem are provided by the development host through the debugger interface (JTAG, ICE, SWD etc).
Generally your compiler's library will provide you with hooks or stubs so that you can implement drivers for alternative stream I/O devices, so for example you could implement one so that printf will output to an LCD display if your device has one. This is called "retargetting".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With