C programs that draw an ASHOK CHAKRA
Write graphics C programs that draw an ASHOK CHAKRA
C programs Solve example to draw an ASHOK CHAKRA
C program Source Code to draw an ASHOK CHAKRA
C program Code to draw an ASHOK CHAKRA
#include"graphics.h"
#include"stdlib.h"
#include"stdio.h"
#include"conio.h"
#include"math.h"
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int radius = 100;
float angle = (360/24)*3.142/180,newangle = 0.0;
int nx,ny,i;
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
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;
circle(midx, midy, radius);
for(i = 0; i" 24; i++)
{
nx = radius*cos(newangle)-0*sin(newangle);
ny = radius*sin(newangle)+0*cos(newangle);
line(midx,midy,midx+nx,midy-ny);
newangle += angle;
}
/* clean up */
getch();
closegraph();
return 0;
}