C progarmming for drawing eclipse

kamal kumar rajak By kamal kumar rajak, 28th Nov 2014 | Follow this author | RSS Feed | Short URL http://nut.bz/f5y7lf8z/
Posted in Wikinut>Writing>Graphology

C is a basic and structural programming language through which we can made games, graphics and all software which are useful to users. here i m showing you how to draw eclipse using c .It is better to use turbo c for this program.so here is program-

programming

#include<graphics.h>
#include<math.h>
#include<stdio.h>
#include<conio.h>
void symm(int,int,int,int);
void draw_ellipse(int ,int);
int xc,yc;

void main()
{ int a,b;

int gdriver=DETECT,gmode,gerror;
clrscr();
initgraph(&gdriver,&gmode,"C\\Turboc3\\BGI");

printf("Enter the center coordinates");
scanf("%d%d",&xc,&yc);

printf("Enter the length of major axis and minor axis");
scanf("%d%d",&a,&b);
printf("The ellipse drawn is shown below");

draw_ellipse(a,b);
getch();
}

void draw_ellipse(int a,int b)
{
int d1,d2,dold,dini,dnew;
int x=0;
int y=b;
d1=b*b+a*a*(-b+(1/4));

while(b*b*x>=a*a*y)
{
if(d1<0)
{
x++;
d1=d1+3*b*b+2*b*b*x;
}
else
{
x++;
y--;
d1=d1+3*b*b+2*b*b*x-2*a*a*y+2*a*a;
}
symm(x,y,xc,yc);
}
d2=b*b*(x+1/2)*(x+1/2)+a*a*(y-1)*(y-1)-a*a*b*b;

while(b*b*x<=a*a*y)
{
if(d2>0)
{
y--;
d2=d2+a*a*(3-2*y);
}
else
{
x++;
y--;
d2=d2+2*b*b*(x+1)+a*a*(3-2*y);
}
symm(x,y,xc,yc);
}
}
void symm(int x,int y,int xc,int yc)
{

putpixel(xc+x,yc+y,RED);
putpixel(xc-x,yc-y,RED);
putpixel(xc+x,yc-y,RED);
putpixel(xc-x,yc-y,RED);

}

Tags

All People, All Programmer, All Society, All Students, All Students And Common People

Meet the author

author avatar kamal kumar rajak
LIFE BRINGS KAVI KHUSI
KAVI GHAM...
SO
ENJOY EVERY PAL
WHO KNOWS
KAL HO NA HO......

Share this page

moderator johnnydod moderated this page.
If you have any complaints about this content, please let us know

Comments

author avatar Retired
15th Apr 2015 (#)

It's all beyond me I'm afraid!

Reply to this comment

author avatar Vigrxプラス
30th Sep 2017 (#)

シアリス:http://www.shanghaikanpo.com/view/1654.html
レビトラ:http://www.shanghaikanpo.com/view/1656.html
levitra:http://www.shanghaikanpo.com/view/1655.html
Cialis:http://www.shanghaikanpo.com/view/1654.html
蟻力神:http://www.shanghaikanpo.com/view/1660.html
リドスプレー:http://www.shanghaikanpo.com/view/1126.html
MaxMan:http://www.shanghaikanpo.com/view/1084.html
魔根:http://www.shanghaikanpo.com/view/1458.html
マカ:http://www.shanghaikanpo.com/view/1129.html
妖姫:http://www.shanghaikanpo.com/view/1518.html
D10:http://www.shanghaikanpo.com/view/1108.html
同仁烏鶏白鳳丸:http://www.shanghaikanpo.com/view/1396.html


街頭覇王:http://www.shanghaikanpo.com/view/1696.html
vigrxプラス:http://www.shanghaikanpo.com/view/1631.html

Reply to this comment

Add a comment
Username
Can't login?
Password