Document
Document
#include <stdio.h>
#include <graphics.h>
Int dx = x2 – x1;
Int dy = y2 – y1;
Int steps;
Steps = abs(dx);
} else {
Steps = abs(dy);
Float x = x1;
Float y = y1;
Putpixel(round(x), round(y), WHITE);
X += x_increment;
Y += y_increment;
Int main() {
Getch();
Closegraph();
Return 0;
This program uses the graphics.h library for graphics operations, which is
commonly available in Turbo C/C++ compiler. Adjust the coordinates x1, y1,
x2, y2 to draw different lines.
Write a program to draw the circle with DDA.
program to draw a circle using the DDA (Digital Differential Analyzer) algorithm:
#include <stdio.h>
#include <graphics.h>
Int x = radius;
Int y = 0;
Int dx = 1;
Int dy = 1;
While (x >= y) {
Putpixel(xc + x, yc + y, WHITE);
Putpixel(xc – x, yc + y, WHITE);
Putpixel(xc + x, yc – y, WHITE);
Putpixel(xc – x, yc – y, WHITE);
Putpixel(xc + y, yc + x, WHITE);
Putpixel(xc – y, yc + x, WHITE);
Putpixel(xc + y, yc – x, WHITE);
Putpixel(xc – y, yc – x, WHITE);
If (err <= 0) {
Y++;
Err += dy;
Dy += 2;
If (err > 0) {
x--;
dx += 2;
Int main() {