'In c,I developed game using graphics.h but in game blinking of colour is there

In c I made game and in this game the c program execution speed is slow thatwise the function cleardevice() use to flicker(blinking) the screen. And I am using turbo c.so how to avoid flickering (blinking in the screen.and also tell me suggestions about writing the code because I am beginner coder.

#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<time.h>
#define l getmaxx()
#define b getmaxy()
int go=1,x=0,y=0,e,w=0,s,scr=0,d=10,sp=2;
char sc[9],c;
void scorce()
{
 sprintf(sc,"%d",scr);
outtextxy(l-130,30,"score:");
  outtextxy(l-60,30,sc);
}
void randcar()
{
 int c;
 if(e!=3)
 {
  c=rand()%10;
  s=(rand()%(l-200-200+1-50))+(200);
  }
 if(c==3 ||e==3)
 {
   e=3;
   rectangle(s,10+w,s+50,110+w);
   if((scr==100 ||scr==200||scr==300||scr==400||scr==500||scr==50)&&10+w>450)
   d=d+1;
   w=w+d;

 }
 if(10+w>b)
 {
 scr=scr+10;
 e=0;
 w=0;
 }
}
void input()
{
   if(kbhit())
   {
    c=getch();
    }
    if(c!='a' &&c!='d' &&
    c!='p'&& c!='w')
    {
    c='d';
    }
    switch(c)
    {
      case 'a':
      x=x+sp;
      break;
      case 'd':
      y=y+sp;
      break;
      case 'p':
      exit(0);
      break;
      case 'w':
      break;
    }
     if((scr==100 ||scr==200||scr==300||scr==400||scr==500||scr==50)&&10+w>450)
      sp=sp+2;
}
void car()
{
  rectangle(l/2-75-x+y,b-100,l/2-25-x+y,b-10);
  setfillstyle(1,4);
  floodfill(l/2-70-x+y,b-90,WHITE);
  if(l/2-75-x+y<200)
  go=0;
  if(l/2-25-x+y>l-200)
  go=0;
  if((l/2-25-x+y>s &&l/2-25-x+y<s+50)&&b-100<w+110)
  go=0;
    if((l/2-75-x+y<s+50 &&l/2-75-x+y>s)&&b-100<w+110)
  go=0;

}
void strip(int c)
{
for(int i=0;i<200*b;i=i+130)
{
rectangle(l/2-5,i-c,l/2+5,90+i-c);
setfillstyle(SOLID_FILL,WHITE);
floodfill(l/2,89+i-c,WHITE);
floodfill(l/2,1+i-c,WHITE);
}

}
void border()
{    rectangle(l,b,0,0);
 line(200,0,200,b);
 line(l-200,0,l-200,b);
 setfillstyle(1,9);// here is colour 
 floodfill(10,10,15);
 floodfill(l-10,b-10,15);

}

int main()
{ srand(time(0));
    int gd=DETECT,gm;
int c=0,x=10;
  clrscr();
   initgraph(&gd,&gm,"C:\\TC\\BGI");

   while(go)
    {
       car();
      strip(c);

      input();
     scorce();
   border();
    randcar();
   c=c+x;
     if((scr==100 ||scr==200||scr==300||scr==400||scr==500||scr==50)&&10+w>450)
   x=x+10;
   if(c>13000)
   c=0;
 delay(50);
   cleardevice();
border();


   }
   cleardevice();
   int color=rand()%15;
   setbkcolor(color);
   settextstyle(7,0,6);
   outtextxy(170,200,"GAME OVER");
   settextstyle(3,0,3);
   outtextxy(300,300,sc);
    getch();
   closegraph();
   return 0;
}

In comment //here is colour,there is colour blinking.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source