Social Icons

Saturday, 1 February 2014

HEAD AND TAIL coin game IN CLANGUAGE

         HEAD AND TAIL coin game IN C-LANGUAGE


                                                     HEAD                                 TAIL

SOURCE CODE :-

INSTRUCTIONS                                                                                                        



  • JUST COPY THE    BELOW CODE AND PAST  IN YOUR TC                   

#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>

int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int stangle = 0, endangle = 360;
int xradius , yradius = 60;

/* initialize graphics, local variables */
initgraph(&gdriver, &gmode, "f:\\tc\\bgi");

/* read result of initialization */
errorcode = graphresult();

if (errorcode != grOk)
/* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
/* terminate with an error code */
}

midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());

int k=1; //for head and tail//
int b=0; //for tail loop//


settextstyle(2,0,0);
/* draw ellipse */

while(!kbhit())
{


 for(int a=60;a>=0;a=a-1)
 {
  cleardevice();

  xradius=a;


 if(a==0)
 {

  k=k+1;
  for(b=a;b<=60;b++)

   {
   cleardevice();
   xradius=b;


   if(k%2==0)
   {
   outtextxy(midx-10,midy-90,"TAIL");
   setfillstyle(4,1);
   }

   else
   {
   outtextxy(midx-10,midy-90,"HEAD");
   setfillstyle(5,3);
   }

   if(b>0 && b<57)

    {
    int xradius1=b-3;
    fillellipse(midx,midy,xradius1+1, yradius);

    fillellipse(midx,midy,xradius1+2, yradius);

    fillellipse(midx,midy,xradius1+3, yradius);
   }

   outtextxy(10,5,"PROGRAM:TO SHOW THE ROTATION OF A COIN");

   fillellipse(midx,midy,xradius, yradius);
   delay(25);
  }

 }

if(a<57>0)
{
 int xradius1=a+3;
 fillellipse(midx,midy,xradius1-1, yradius);

 fillellipse(midx,midy,xradius1-2, yradius);

 fillellipse(midx,midy,xradius1-3, yradius);
}

  if (k%2==0)
  {
  outtextxy(midx-10,midy-90,"TAIL");
  setfillstyle(4,1);
  }

  else
  {
  outtextxy(midx-10,midy-90,"HEAD");
  setfillstyle(5,3);
  }

  outtextxy(10,5,"PROGRAM:TO SHOW THE ROTATION OF A COIN");

  fillellipse(midx,midy,xradius, yradius);

  delay(25);

}
}

/* clean up */

getch();
closegraph();
return 0;
}

No comments:

Post a Comment