Question

Write a program in C/C++ to implement Bresenham’s line generation algorithm.

16 Sep 2022
Answer :
Word Count : 345

Here's a C++ program that implements Bresenham's line generation algorithm:


#include <iostream>
#include <graphics.h>

using namespace std;

void drawLine(int x0, int y0, int x1, int y1) {
  int dx = abs(x1 - x0);
  int dy = abs(y1 - y0);
  int sx, sy;
  if (x0 < x1) {
    sx = 1;
  } else {
    sx = -1;
  }
  if (y0 < y1) {
    sy = 1;
  } else {
    sy = -1;
 

___ _________ _______ _____ _________ ________ _______ ______.
_________ ___ _________ ___ ______ __________ ________ ______ ____.
_________ ____ _______ ______ _____.
___ ________ ____ _____ ___ ____ ____ _____ _____ _____ ________.
_____ ______ ___ ____ _______ ________ ___ ___ ____ _______.
_______ ______ __________ __________ _____ ___ ________ _______ ___ ____ __________.
_____ _____ ______ ___ _________ ___ ________ ________ ________ _____ _____ ____.
____ ________ _______ _______ _______ ______ _________ _________.
___ __________ ______ ________ _________ ______ _____ ___ ____ ________ _______.
_____ __________ _____ _________ _____ _____ ____ _________.
_________ _______ _____ ________ _________ _____ _________.
___ _________ __________ _____ ___ ___ ___ _____ ______ _________.
____ _________ ____ _________ _________ ________ _________ __________ ______ _________ _______.
________ __________ _______ ___ _____ _________ ________ _________ ___ _______ ______.
_____ _________ _________ __________ ______ ___.
____ ______ ________ _______ _____ __________ ____ ____ __________ _________.
_______ _________ ____ _______ ________ ___ __________ ________ _____ ______.
______ ____ __________ ______ _________.
________ ______ ____ _______ _________ ________.
______ ____ ____ _________ __________ _______ _______ _______ ___ _____ _________ _____.
_________ _______ __________ ________ _________ ______ _____ _______.
____ _________ _______ ________ _______ _________ ___ ______ _______.
________ ___ ____ ________ _________ _______ ___ _____ ______.
_______ _________ ___ ________ ___ _______ _______ __________ ___ ___ ______ _________.
____ ___ ________ ______ _______ ___ __________ _____ ____ ______ __________.
_________ _________ __________ __________ _______ ________.
__________ _____ _______ __________ ___.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MCSL 54 2022 2023 - Write a program in C/C++ to implement Bresenham’s line generatio | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→