0% found this document useful (0 votes)
4 views

computer graphics-basic3

The document contains a C program that draws a circle using the Bresenham's circle drawing algorithm. It prompts the user to enter the center coordinates and radius of the circle, then initializes the graphics mode and plots the circle using pixel manipulation. The program concludes by closing the graphics window after user input.

Uploaded by

hajisaad029
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

computer graphics-basic3

The document contains a C program that draws a circle using the Bresenham's circle drawing algorithm. It prompts the user to enter the center coordinates and radius of the circle, then initializes the graphics mode and plots the circle using pixel manipulation. The program concludes by closing the graphics window after user input.

Uploaded by

hajisaad029
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Name: Saad Haji Enrollment no: 23111590411 Class : C03KB

Batch: 1 Subject: CGR Practical: 4


Program
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
void main(){
int gd=DETECT, gm;
int x,y,xc,yc,r,d;
clrscr();
printf("\n enter the center of the circle:");
scanf("%d %d", &xc, &yc);
printf("\n enter the radius of the circle:");
scanf("%d", &r);
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
d = 3 - 2 * r;
x = 0;
y = r;
while(x <= y){
putpixel(x+xc, y+yc, WHITE);
putpixel(x+xc, -y+yc, WHITE);
putpixel(-x+xc, y+yc, WHITE);
putpixel(-x+xc, -y+yc, WHITE);
putpixel(y+xc, x+yc, WHITE);
putpixel(y+xc, -x+yc, WHITE);
putpixel(-y+xc, x+yc, WHITE);
putpixel(-y+xc, -x+yc, WHITE);
if(d < 0){
d = d + 4 * x + 6;
}
else{
d = d + 4 * (x - y) + 10;
y = y - 1;
}
x = x + 1;
}
getch();
closegraph();
}
Output:

You might also like