<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Software Programs | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/software-programs/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Fri, 02 Oct 2009 10:07:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>C Program to display a line graph using midpoint line algorithm.</title>
		<link>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-display-a-line-graph-using-midpoint-line-algorithm/</link>
					<comments>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-display-a-line-graph-using-midpoint-line-algorithm/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Fri, 02 Oct 2009 10:07:21 +0000</pubDate>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[c graphics]]></category>
		<category><![CDATA[Software Programs]]></category>
		<category><![CDATA[line graph]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=823</guid>

					<description><![CDATA[<p>Program to display a line graph using midpoint line algorithm. The input to the program is a set of data corresponding to the X and Y-axes. Data parts are to be displayed as asterisk (*) according to the input specification.</p>
<p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-display-a-line-graph-using-midpoint-line-algorithm/">C Program to display a line graph using midpoint line algorithm.</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Program to display a line graph using midpoint line algorithm. The input to the program is a set of data corresponding to the X and Y-axes. Data parts are to be displayed as asterisk (*) according to the input specification.</p>
<pre lang="c" escaped="true" line="1">
#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>
#include<conio.h>

#define MAX 20

void swap(int* a,int* b)
{
	int t=*a;
	*a=*b;
	*b=t;
}

void midpointline(int x1,int y1,int x2,int y2)
{
	int dx,dy,d,incry,incre,incrne,slopegt1=0;
	dx=abs(x1-x2);dy=abs(y1-y2);
	if(dy>dx)
	{
		swap(&x1,&y1);
		swap(&x2,&y2);
		swap(&dx,&dy);
		slopegt1=1;
	}
	if(x1>x2)
	{
		swap(&x1,&x2);
		swap(&y1,&y2);
	}
	if(y1>y2)
		incry=-1;
	else
		incry=1;
	d=2*dy-dx;
	incre=2*dy;
	incrne=2*(dy-dx);
	while(x1<x2)
	{
		if(d<=0)
			d+=incre;
		else
		{
			d+=incrne;
			y1+=incry;
		}
		x1++;
		if(slopegt1)
			putpixel(y1,x1,WHITE);
		else
			putpixel(x1,y1,WHITE);
	}
}

void main()
{
	int n,i;
	int pt[MAX][2];
	int gd=DETECT,gm;

	printf("Enter the number of points:");
	scanf("%d",&#038;n);

	printf("Enter the x and y coordinates:");
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&#038;pt[i][0],&#038;pt[i][1]);
		pt[i][1]=480 - pt[i][1];
	}

	initgraph(&#038;gd,&#038;gm,"..\\bgi");

	line(1,0,1,480);		// X - Axis
	line(0,479,639,479);		// Y - Axis

	outtextxy(pt[0][0]-2,pt[0][1]-3,"*");

	for(i=0;i<n-1;i++)
	{
		midpointline(pt[i][0],pt[i][1],pt[i+1][0],pt[i+1][1]);
		outtextxy(pt[i+1][0]-2,pt[i+1][1]-3,"*");
	}
	getch();
	closegraph();
}
</pre><p>The post <a href="https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-display-a-line-graph-using-midpoint-line-algorithm/">C Program to display a line graph using midpoint line algorithm.</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/c-tutorials/c/graphics/c-program-to-display-a-line-graph-using-midpoint-line-algorithm/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
