Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  a.cpp
Language: C/C++
Code:
#include<math.h>
#include<iostream>
#include<stdlib.h>
#include<graphics.h>
#include <unistd.h>   //header file for usleep function
using namespace std;
int x1=300,y11=180,x,y;
void display(double i)
{
     circle(300,130,50);
     line(210,60,210,320);
     line(210,60,390,60);
     line(390,60,390,320);
     line(210,320,390,320);
     outtextxy(295,88,"12");
     outtextxy(260,130,"9");
     outtextxy(340,130,"3");
     outtextxy(295,168,"6");
     line(300,130,300,98);
 
     line(300,98,297,101);
     line(300,98,303,101);
     line(337,130,300,130);
     line(337,130,334,127);
     line(337,130,334,133);
     x=x1+95*cos(i);
     y=y11+95*sin(i);
     line(x1,y11,x,y);
     circle(x,y,10);
        usleep(15000);  //delay function and time specified in miliseconds
        cleardevice();
}

int main()
{
     int gd=DETECT,gm,j=50;
        char ch;
     double i;
     initgraph(&gd,&gm,NULL);
     do
         {
          for(i=2;i>1;i=i-0.01)
               display(i);
          for(i=1;i<2;i=i+0.01)
               display(i);
          j--;        
        }while(j!=0);
          
}



/*-----------Output---------

>g++ ass12.cpp -lgraph
>./a.out
*/
Comments: