B.Tech / M.
tech Lab report format
For CSE Department,NIT Mizoram
General Format:
Your lab reports are to be typed or hand written , single spaced (extra line of space between paragraphs), with
normal one-inch margins. Be careful to have correct spelling and proper English grammar, as these will be taken into
consideration when your report is graded. Back side of the page should be used only for Images and evolution
purpose.
Contents of the Lab Report
1. Title Page (required):
Your title page must conform to the approved title page for the Computer Science and Engineering Department NIT
Mizoram.
2. Table of Contents
3. Experiments:
All the experiment must contain the following:
Program/Experiment no
Title of the Program/Experiment
Objective : The objective is a concise statement outlining the purpose of the experiment. e.g. To
determine the boiling point of H2O
Description : overview, algorithm, Example etc.
Source Program
Output
Sample Copy
Computer Graphics Laboratory (CSP 1604)
Lab Sessional Report Submitted to
National Institute of Technology, Mizoram
for
Bachelor of Technology
in
Computer Science and Engineering Department
Submitted by
[STUDENT NAME] (BTXXCS001 )
Course Faculty
Mrs. Dipanwita Debnath
Department of Computer Science and Engineering
NATIONAL INSTITUTE OF TECHNOLOGY
Mizoram-796012, India
May-2037
Table of Contents
Exp. Page Date of Date of Faculty
Name of the Experiments
No no Experiment Submission Signature
1 BRESENHAM’S Algorithm For Line 1-3 01-01-2017
Drawing
Date: Page no:
For each program you have to write :
Program/Experiment No:1
Program/Experiment Name: BRESENHAM’S Algorithm For Line Drawing.
Description: The Bresenham algorithm is an incremental scan conversion algorithm. The big
advantage of this algorithm is that, it uses only integer calculations. Moving across the x axis in unit
intervals and at each step choose between two different y coordinates.
Algorithm:
1. Start.
2. Declare variables x,y,x1,y1,x2,y2,p,dx,dy and also declare gdriver=DETECT,gmode.
3. Initialize the graphic mode with the path location in TC folder.
4. Input the two line end-points and store the left end-points in (x1,y1).
5. Load (x1,y1) into the frame buffer; that is, plot the first point put x=x1,y=y1.
6. Calculate dx=x2-x1 and dy=y2-y1,and obtain the initial value of decision parameter p as:
a. p=(2dy-dx).
7. Starting from first point (x,y) perform the following test:
8. Repeat step 9 while(x<=x2).
9. If p<0,next point is (x+1,y) and p=(p+2dy).
10. Otherwise, the next point to plot is (x+1,y+1) and p=(p+2dy-2dx).
11. Place pixels using putpixel at points (x,y) in specified colour.
12. Close Graph.
13. Stop.
Source Code:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int x,y,x1,y1,x2,y2,p,dx,dy;
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"C:\\tc\\BGI:");
printf("\nEnter the x-coordinate of the first point ::");
scanf("%d",&x1);
printf("\nEnter the y-coordinate of the first point ::");
scanf("%d",&y1);
printf("\nEnter the x-coordinate of the second point ::");
Date: Page no:
scanf("%d",&x2);
printf("\nEnter the y-coordinate of the second point ::");
scanf("%d",&y2);
x=x1;
y=y1;
dx=x2-x1;
dy=y2-y1;
putpixel(x,y,2);
p=(2dy-dx);
while(x<=x2)
{
if(p<0)
{
x=x+1;
p=2*x-dx;
}
else
{
x=x+1;
y=y+1;
p=p+2*dy;
}
putpixel(x,y,7);
}
getch();
closegraph();
}
Output: