C++ program to print your name randomly on the screen with colored text
This program will print the name until we do not press any key through keyboard, there are text colors and text background color is used to print the name.
Name will be print on random positions.
Following functions are used in this program:
1) kbhit() - This function returns true if key is pressed, in the program we are using while(!kbhit()), that mean program will run until any is not pressed. This function is declared in conio.h.
2) randomize() and rand() – Functions are used to generate random numbers, here we are generating random text colors and background colors till color value 16, value of X and Y co-ordinates. Functions are declared in stdlib.h.
3) textcolor(color) – This function is used to define text color, its value will be 0 to 15 (in hexadecimal: 0x00 to 0x0F). Function is declared in conio.h.
4) textbackground(color) – This function is used to define text background color, its value will be 0 to 15 (in hexadecimal: 0x00 to 0x0F). Function is declared in conio.h.
5) gotoxy(x,y) – To define X and Y co-ordinates where text will be printed.
6) cprintf(string..) - This function is similar to printf, but it is used to print the colored text on console output screen. Function is declared in conio.h.
7) delay(milliseconds) – This function is used to hold the program’s execution for given milliseconds, it is using to run loop after given milliseconds in the program. Function is declared in dos.h.
Note: program is compiled and executed on TurboC3 compiler.