Search This Blog

Translate

C graphics program example to draw pie chart,graphics code in c

  computer graphics programs in c, graphics in c language examples, graphics example in c,

C program to display pia chart, c graphics pdf,c graphics tutorial pdf, c graphics examples,c graphics projects,c graphics library, c graphics program examples, c graphics programs source code, graphics program in c, program in c using graphics, c graphics programs with code, simple graphics program in c, graphics under c, graphics.h tutorial, graphics program in c language,

 

Write a graphics C program that accept ‘n’ year and rain fall on that year and display pie chart for it. solve example with source code, 

C graphics pie chart program example with source code, 

learn c graphics, 

How  to write c program to draw draw pie chart,

Write a graphics C program that accept ‘n’ year and rain fall on that year and display pie chart for it.




#include

#include

#include

int main(void){

   int gdriver = DETECT, gmode, errorcode;

   int midx, midy;
   int n,year[10],rain[10],angle,startangle;
   int total = 0,i;
   printf("Enter total number of years ");
   scanf("%d",&n);
   printf("\nEnter %d years and corresponding rain fall value");
   for(i = 0; i < n; i++)
   {
            scanf("%d%d",&year[i],&rain[i]);
            total = total + rain[i];
   }
   /* initialize graphics, local variables */
   initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk){
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1);
   }
   midx = getmaxx() / 2;
   midy = getmaxy() / 2;
   setcolor(WHITE);
   /* draw ellipse */
   startangle = 0;
   for(i = 0; i < n; i++)
   {
            angle = startangle + rain[i]*360/total;
            if(i == n-1)
                        angle = 360;
            pieslice(midx, midy, startangle, angle,100);
            startangle = angle;
            setfillstyle(SOLID_FILL,i+1);
   }
   //floodfill(midx,midy,WHITE);
   /* clean up */
   getch();
   closegraph();
   return 0;
}

computer graphics programs in c, graphics in c language examples, graphics example in c,

C program to display pia chart, c graphics pdf,c graphics tutorial pdf, c graphics examples,c graphics projects,c graphics library, c graphics program examples, c graphics programs source code, graphics program in c, program in c using graphics, c graphics programs with code, simple graphics program in c, graphics under c, graphics.h tutorial, graphics program in c language
 

 

C Program example List

Google+ Badge