C++ program to draw a circle using Cartesian Coordinates technique
Solution:
#include<iostream.h>
#include<graphics.h>
#include<conio.h>
#include<math.h>
void main()
{
int xc, yc, x, y, r;
cout<<"please enter center point of the circle";
cin>>xc>>yc;
cout<<"please enter the radius of the circle";
cin>>r;
int gd=DETECT, gm;
initgraph(&gd,&gm, "..\\bgi");
for(x=r-xc; x<=r+xc; x++)
{
y=yc+sqrt((r*r-(x-xc)*(x-xc)));
putpixel(x,y, RED);
y=yc-sqrt((r*r-(x-xc)*(x-xc)));
putpixel(x,y, BLUE);
}
getch();
}
#include<graphics.h>
#include<conio.h>
#include<math.h>
void main()
{
int xc, yc, x, y, r;
cout<<"please enter center point of the circle";
cin>>xc>>yc;
cout<<"please enter the radius of the circle";
cin>>r;
int gd=DETECT, gm;
initgraph(&gd,&gm, "..\\bgi");
for(x=r-xc; x<=r+xc; x++)
{
y=yc+sqrt((r*r-(x-xc)*(x-xc)));
putpixel(x,y, RED);
y=yc-sqrt((r*r-(x-xc)*(x-xc)));
putpixel(x,y, BLUE);
}
getch();
}
output:
thanks alot
ReplyDeletethanks alot
ReplyDeletenot haw to work dev c++
ReplyDeleteplease send me dev c++
Delete