Created
February 23, 2022 04:06
-
-
Save whopiyush/fdff1ec3dab22877cb96c586d87308ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<iostream.h> | |
| #include<graphics.h> | |
| void drawcircle(int x0, int y0, int radius) | |
| { | |
| int x = radius; | |
| int y = 0; | |
| int err = 0; | |
| while (x >= y) | |
| { | |
| putpixel(x0 + x, y0 + y, 7); | |
| putpixel(x0 + y, y0 + x, 7); | |
| putpixel(x0 - y, y0 + x, 7); | |
| putpixel(x0 - x, y0 + y, 7); | |
| putpixel(x0 - x, y0 - y, 7); | |
| putpixel(x0 - y, y0 - x, 7); | |
| putpixel(x0 + y, y0 - x, 7); | |
| putpixel(x0 + x, y0 - y, 7); | |
| if (err <= 0) | |
| { | |
| y += 1; | |
| err += 2*y + 1; | |
| } | |
| if (err > 0) | |
| { | |
| x -= 1; | |
| err -= 2*x + 1; | |
| } | |
| } | |
| } | |
| int main() | |
| { | |
| int gdriver=DETECT, gmode, error, x, y, r; | |
| initgraph(&gdriver, &gmode, "c:\\turboc3\\bgi"); | |
| cout<<"Enter radius of circle: "; | |
| cin>>r; | |
| cout<<"Enter co-ordinates of center(x and y): "; | |
| cin>>x>>y; | |
| drawcircle(x, y, r); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment