0% found this document useful (0 votes)
398 views1 page

C Graphics Program To Draw A Line

The document contains code for several C graphics programs that draw basic shapes using graphics functions: - It draws a line between two points using the line() function. - It draws a circle with a given radius centered in the screen using circle(). - It draws an ellipse centered in the screen using ellipse().

Uploaded by

Michael Wells
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)
398 views1 page

C Graphics Program To Draw A Line

The document contains code for several C graphics programs that draw basic shapes using graphics functions: - It draws a line between two points using the line() function. - It draws a circle with a given radius centered in the screen using circle(). - It draws an ellipse centered in the screen using ellipse().

Uploaded by

Michael Wells
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/ 1

/* C graphics program to draw a

line */
#include<graphics.h>
#include<graphics.h>
#include<conio.h>
int main() { #include<conio.h>
int gd = DETECT, gm; void main()
/* initialization of graphic {
mode */ int gd=DETECT,gm;
initgraph(&gd, &gm,
"C:\\TC\\BGI");
initgraph(&gd,&gm,"C:\\TC\\bgi");
line(100,100,200, 200); line(150,100,100,200);
getch(); line(100,200,200,200);
closegraph(); line(200,200,150,100);
return 0; line(100,125,200,125);
}
line(100,125,150,225);
line(150,225,200,125);
#include<stdio.h> getch();
#include<graphics.h> closegraph();
#include<conio.h> }
int main(){ #include<graphics.h>
int gd = DETECT,gm; #include<conio.h>
int x ,y ,radius=80;
initgraph(&gd, &gm, main()
"C:\\TC\\BGI"); {
/* Initialize center of circle int gd =
with center of screen */ DETECT,gm,left=100,top=100,right=20
x = getmaxx()/2; 0,bottom=200,x=
y = getmaxy()/2; 300,y=150,radius=50;

outtextxy(x-100, 50, "CIRCLE initgraph(&gd, &gm,


Using Graphics in C"); "C:\\TC\\BGI");
/* Draw circle on screen */
circle(x, y, radius); rectangle(left, top, right,
bottom);
getch(); circle(x, y, radius);
closegraph(); bar(left + 300, top, right +
return 0; 300, bottom);
} line(left - 10, top + 150, left
#include<stdio.h> + 410, top + 150);
#include<graphics.h> ellipse(x, y + 200, 0, 360, 100,
#include<conio.h> 50);
outtextxy(left + 100, top + 325,
"My First C Graphics Program");
int main(){
int gd = DETECT,gm; getch();
int x ,y; closegraph();
initgraph(&gd, &gm, return 0;
"X:\\TC\\BGI"); }
/* Initialize center of ellipse
with center of screen */
x = getmaxx()/2;
y = getmaxy()/2;

outtextxy(x-100, 50, "ELLIPSE


Using Graphics in C");
/* Draw ellipse on screen */
ellipse(x, y, 0, 360, 120, 60);

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

You might also like