#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <dos.h>
#include <conio.h>
int even_or_odd=1;
void main()
{
int x=1,y=4;
char c, name[20];
clrscr();
printf("Enter your name: ");
scanf("%s",&name);
changecolor();
while(!kbhit())
{
srand(time(NULL));
c = rand();
gotoxy(x,y);
cprintf("%c",c);
y++;
if(y==21)
{
x++;
y=4;
}
if(x==80)
{
x=1;
even_or_odd++;
changecolor();
}
gotoxy(35,12);
cprintf(" %s ",name);
}
}
changecolor()
{
if(even_or_odd%2==0)
{
textcolor(BLUE);
}
else textcolor(GREEN);
}
Output: