Showing posts with label create a circle. Show all posts
Showing posts with label create a circle. Show all posts

Saturday, 17 December 2011

Draw a colorful Circle


#include<graphics.h>
#include<conio.h>
#include<stdio.h>

void main(void)
{
    int driver=DETECT, mode;
    int xc1=320, yc1=240;


       initgraph(&driver, &mode, "c:\\TC\\bgi" );
         setcolor(7);                     //edge color
         setfillstyle(SOLID_FILL,GREEN);  // fill inside the circle
         circle(xc1,yc1,100);             // create a circle
         floodfill(xc1,yc1,7);            // flood color
     getch();
    closegraph();
}


Output:
















If you have any question, you can ask me freely...

Friday, 18 November 2011

How to Initialize Graphics mode in C language

/*Header Files*/
#include<stdio.h>                  //for input/output purpose
#include<conio.h>                 //for getch() function
#include<graphics.h>            //for graphics functions
void main()
{
         int driver=DETECT, mode;                               //auto detect the driver
         int x=320, y=240, radius=100;                            // initialization
           initgraph(&driver , &mode , "c:\\tc\\bgi");  // all necessary graphics files in BGI folder
                  circle(x , y, radius);                                            //create a circle
         getch();                                                          // waits for key press
         closgraph();                                                    //close graphics mode
}

The above program will give the following output: