0% found this document useful (0 votes)
45 views4 pages

Graphics

C program to draw graphics

Uploaded by

Vaibhav Bhor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views4 pages

Graphics

C program to draw graphics

Uploaded by

Vaibhav Bhor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

Write a Program to draw basic graphics construction like


line, circle, arc, ellipse and rectangle.

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

main()
{
int gd = DETECT,gm,left=100,top=100,right=200,bottom=200,x= 300,y=150,radius=50;

initgraph(&gd, &gm, "C:\\TC\\BGI");

rectangle(left, top, right, bottom);


circle(x, y, radius);
bar(left + 300, top, right + 300, bottom);
line(left - 10, top + 150, left + 410, top + 150);
ellipse(x, y + 200, 0, 360, 100, 50);
outtextxy(left + 100, top + 325, "My first C graphics program");

getch();
closegraph();
return 0;
}

2. C program to draw circles in circles in two different


colors.

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

int main()
{
int gd = DETECT, gm, x, y, color, angle = 0;
struct arccoordstype a, b;

initgraph(&gd, &gm, "C:\\TC\\BGI");


delay(2000);

while (angle <= 360)


{
setcolor(BLACK);
arc(getmaxx()/2, getmaxy()/2, angle, angle + 2, 100);
setcolor(RED);
getarccoords(&a);
circle(a.xstart, a.ystart, 25);
setcolor(BLACK);
arc(getmaxx()/2, getmaxy()/2, angle, angle + 2, 150);
getarccoords(&a);
setcolor(GREEN);
circle(a.xstart, a.ystart, 25);
angle = angle+5;
delay(50);

}
3.program to draw bar chart

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

int main()
{
int gd = DETECT, gm, x, y, color, angle = 0;
struct arccoordstype a, b;

initgraph(&gd, &gm, "C:\\TC\\BGI");


delay(2000);

while (angle <= 360)


{
setcolor(BLACK);
arc(getmaxx()/2, getmaxy()/2, angle, angle + 2, 100);
setcolor(RED);
getarccoords(&a);
circle(a.xstart, a.ystart, 25);
setcolor(BLACK);
arc(getmaxx()/2, getmaxy()/2, angle, angle + 2, 150);
getarccoords(&a);
setcolor(GREEN);
circle(a.xstart, a.ystart, 25);
angle = angle+5;
delay(50);
}

getch();
closegraph();
return 0;
}

4. Program to Draw Eclipse using Graphics


#include<graphics.h>

#include<conio.h>

main()

int gd = DETECT, gm;

initgraph(&gd, &gm, "C:\\TC\\BGI");

ellipse(100, 100, 0, 360, 50, 25);

getch();

closegraph();

return 0;

5. Draw circle using grahics function.


#include<stdio.h>

#include<graphics.h>

int main(){

int gd = DETECT,gm;

int x ,y ,radius=80;

initgraph(&gd, &gm, "C:\\TC\\BGI");

/* Initialize center of circle with center of screen */

x = getmaxx()/2;
y = getmaxy()/2;

outtextxy(x-100, 50, "CIRCLE Using Graphics in C");

/* Draw circle on screen */

circle(x, y, radius);

closegraph();

return 0;

You might also like