0% found this document useful (0 votes)
44 views3 pages

Circle

The document contains code snippets for drawing basic shapes using graphics in C programming. The first code sample draws a circle in the center of the screen with a radius of 80 pixels. The second code draws a rectangle from coordinates (150,50) to (400,150) and a bar from (150,200) to (400,350). The third code sample draws an ellipse centered at the screen center with radii of 120 and 60 pixels spanning 0 to 360 degrees.

Uploaded by

Anand Kalani
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)
44 views3 pages

Circle

The document contains code snippets for drawing basic shapes using graphics in C programming. The first code sample draws a circle in the center of the screen with a radius of 80 pixels. The second code draws a rectangle from coordinates (150,50) to (400,150) and a bar from (150,200) to (400,350). The third code sample draws an ellipse centered at the screen center with radii of 120 and 60 pixels spanning 0 to 360 degrees.

Uploaded by

Anand Kalani
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/ 3

CIRCLE

#include<stdio.h>
#include<graphics.h>
#include<conio.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);

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

OUTPUT
C program to draw rectangle and bar using graphics

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

int main(){
int gd = DETECT,gm;
initgraph(&gd, &gm, "C:\\TC\\BGI");

/* Draw rectangle on screen */


rectangle(150, 50, 400, 150);

/* Draw Bar on screen */


bar(150, 200, 400, 350);

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

C program to draw an eclipse using graphics

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

int main(){
int gd = DETECT,gm;
int x ,y;
initgraph(&gd, &gm, "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