You are here

C program to draw circles in circles

This program draws circles in circles in two different colors.

C programming code

  1. #include<graphics.h>
  2. #include<conio.h>
  3. #include<dos.h>
  4.  
  5. main()
  6. {
  7.    int gd = DETECT, gm, x, y, color, angle = 0;
  8.    struct arccoordstype a, b;
  9.  
  10.    initgraph(&gd, &gm, "C:\\TC\\BGI");
  11.    delay(2000);
  12.  
  13.    while(angle<=360)
  14.    {
  15.       setcolor(BLACK);
  16.       arc(getmaxx()/2,getmaxy()/2,angle,angle+2,100);
  17.       setcolor(RED);
  18.       getarccoords(&a);
  19.       circle(a.xstart,a.ystart,25);
  20.       setcolor(BLACK);
  21.       arc(getmaxx()/2,getmaxy()/2,angle,angle+2,150);
  22.       getarccoords(&a);
  23.       setcolor(GREEN);
  24.       circle(a.xstart,a.ystart,25);
  25.       angle = angle+5;
  26.       delay(50);
  27.    }
  28.  
  29.    getch();
  30.    closegraph();
  31.    return 0;
  32. }