<?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>polynomials | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/polynomials/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Mon, 31 Jan 2011 10:47: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 multiply two polynomials maintained as linked lists</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-multiply-two-polynomials-maintained-as-linked-lists/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-multiply-two-polynomials-maintained-as-linked-lists/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 03 Feb 2011 10:45:58 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[polynomials]]></category>
		<category><![CDATA[Linked Lists]]></category>
		<category><![CDATA[struct]]></category>
		<category><![CDATA[multiply]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1248</guid>

					<description><![CDATA[<p>#include class poly { private : struct polynode { float coeff ; int exp ; polynode *link ; } *p ; public : poly( ) ; void poly_append ( float c, int e ) ; void display_poly( ) ; void poly_multiply ( poly &#038;p1, poly &#038;p2 ) ; void padd ( float c, int e</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-multiply-two-polynomials-maintained-as-linked-lists/">C++ program to multiply two polynomials maintained as linked lists</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#include <iostream.h>
class poly
{
	private :
		struct polynode
		{
			float coeff ;
			int exp ;
			polynode *link ;
		} *p ;
	public :
		poly( ) ;
		void poly_append ( float c, int e ) ;
		void display_poly( ) ;
		void poly_multiply ( poly &p1, poly &p2 ) ;
		void padd ( float c, int e ) ;
		~poly( ) ;
} ;
poly :: poly( )
{
	p = NULL ;
}
void poly :: poly_append ( float c, int e )
{
	polynode *temp ;
	temp = p ;
	if ( temp == NULL )
	{
		temp = new polynode ;
		p = temp ;
	}
	else
	{
		while ( temp -> link != NULL )
			temp = temp -> link ;
		temp -> link = new polynode ;
		temp = temp -> link ;
	}
	temp -> coeff = c ;
	temp -> exp = e ;
	temp -> link = NULL ;
}
void poly :: display_poly( )
{
	polynode *temp = p ;
	int f = 0 ;
	while ( temp != NULL )
	{
		if ( f != 0 )
		{
			if ( temp -> coeff > 0 )
				cout << " + " ;
			else
				cout << " " ;
		}
		if ( temp -> exp != 0 )
			cout << temp -> coeff << "x^" << temp -> exp ;
		else
			cout << temp -> coeff ;
		temp = temp -> link ;
		f = 1 ;
	}
}
void poly :: poly_multiply ( poly &p1, poly &p2 )
{
	polynode *temp1, *temp2 ;
	float coeff1, exp1 ;
	temp1 = p1.p ;
	temp2 = p2.p ;
	if ( temp1 == NULL && temp2 == NULL )
		return ;
	if ( temp1 == NULL )
		p = p2.p ;
	else
	{
		if ( temp2 == NULL )
			p = temp1 ;
		else		{
			while ( temp1 != NULL )
			{
				while ( temp2 != NULL )
				{
					coeff1 = temp1 -> coeff * temp2 -> coeff ;
					exp1 = temp1 -> exp + temp2 -> exp ;
					temp2 = temp2 -> link ;
					padd ( coeff1, exp1 ) ;
				}
				temp2 = p2.p ;
				temp1 = temp1 -> link ;
			}
		}
	}
}
void poly :: padd ( float c, int e )
{
	polynode *r, *temp ;
	temp = p ;
	if ( temp == NULL || c > temp -> exp )
	{
		r = new polynode ;
		r -> coeff = c ;
		r -> exp = e ;
		if ( p == NULL )
		{
			r -> link = NULL ;
			p = r ;
		}
		else
		{
			r -> link = temp ;
			p = r ;
		}
	}
	else
	{
		while ( temp != NULL )
		{
			if ( temp -> exp == e )
			{
				temp -> coeff += c ;
				return ;
			}
			if ( temp -> exp > c && ( temp -> link -> exp < c ||
						temp -> link == NULL ) )
			{
				r = new polynode ;
				r -> coeff = c;
				r -> exp = e ;
				r -> link = NULL ;
				temp -> link = r ;
				return ;
			}
			temp = temp -> link ;
		}
		r -> link = NULL ;
		temp -> link = r ;
	}
}
poly :: ~poly( )
{
	polynode *q ;
	while ( p != NULL )
	{
		q = p -> link ;
		delete p ;
		p = q ;
	}
}
void main( )
{
	poly p1 ;
	p1.poly_append ( 3, 5 ) ;
	p1.poly_append ( 2, 4 ) ;
	p1.poly_append ( 1, 2 ) ;

	cout << "\nFirst polynomial: " << endl ;
	p1.display_poly( ) ;
	poly p2 ;
	p2.poly_append ( 1, 6 ) ;
	p2.poly_append ( 2, 5 ) ;
	p2.poly_append ( 3, 4 ) ;
	cout << "\nSecond polynomial: " << endl ;
	p2.display_poly( ) ;
	poly p3 ;
	p3.poly_multiply ( p1, p2 ) ;
	cout << "\nResultant polynomial: " << endl ;
	p3.display_poly( ) ;
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-multiply-two-polynomials-maintained-as-linked-lists/">C++ program to multiply two polynomials maintained as linked lists</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-multiply-two-polynomials-maintained-as-linked-lists/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>C++ program to add two polynomials maintained using Linked Lists</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-add-two-polynomials-maintained-using-linked-lists/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-add-two-polynomials-maintained-using-linked-lists/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 03 Feb 2011 10:29:39 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[polynomials]]></category>
		<category><![CDATA[Linked Lists]]></category>
		<category><![CDATA[struct]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1246</guid>

					<description><![CDATA[<p>#include class poly { private : struct polynode { float coeff ; int exp ; polynode *link ; } *p ; public : poly( ) ; void poly_append ( float c, int e ) ; void display_poly( ) ; void poly_add( poly &#038;l1, poly &#038;l2 ) ; ~poly( ) ; } ; poly :: poly(</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-add-two-polynomials-maintained-using-linked-lists/">C++ program to add two polynomials maintained using Linked Lists</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#include <iostream.h>
class poly
{
	private :
		struct polynode
		{
			float coeff ;
			int exp ;
			polynode *link ;
		} *p ;
	public :
		poly( ) ;
		void poly_append ( float c, int e ) ;
		void display_poly( ) ;
		void poly_add( poly &l1, poly &l2 ) ;
		~poly( ) ;
} ;
poly :: poly( )
{
	p = NULL ;
}
void poly :: poly_append ( float c, int e )
{
	polynode *temp = p ;
	if ( temp == NULL )
	{
		temp = new polynode ;
		p = temp ;
	}
	else
	{
		while ( temp -> link != NULL )
			temp = temp -> link ;
		temp -> link = new polynode ;
		temp = temp -> link ;
	}
	temp -> coeff = c ;
	temp -> exp = e ;
	temp -> link = NULL ;
}
void poly :: display_poly( )
{
	polynode *temp = p ;
	int f = 0 ;

	cout << endl ;
	while ( temp != NULL )
	{
		if ( f != 0 )
		{
			if ( temp -> coeff > 0 )
				cout << " + " ;
			else
				cout << " " ;
		}
		if ( temp -> exp != 0 )
			cout << temp -> coeff << "x^" << temp -> exp ;
		else
			cout << temp -> coeff ;
		temp = temp -> link ;
		f = 1 ;
	}
}
void poly :: poly_add ( poly &l1, poly &l2 )
{
	polynode *z ;
	if ( l1.p == NULL && l2.p == NULL )
		return ;
	polynode *temp1, *temp2 ;
	temp1 = l1.p ;
	temp2 = l2.p ;
	while ( temp1 != NULL && temp2 != NULL )
	{
		if ( p == NULL )
		{
			p = new polynode ;
			z = p ;
		}
		else
		{
			z -> link = new polynode ;
			z = z -> link ;
		}
		if ( temp1 -> exp < temp2 -> exp )
		{
			z -> coeff = temp2 -> coeff ;
			z -> exp = temp2 -> exp ;
			temp2 = temp2 -> link ;
		}
		else
		{
			if ( temp1 -> exp > temp2 -> exp )
			{
				z -> coeff = temp1 -> coeff ;
				z -> exp = temp1 -> exp ;
				temp1 = temp1 -> link ;
			}
			else
			{
				if ( temp1 -> exp == temp2 -> exp )
				{
					z -> coeff = temp1 -> coeff + temp2 -> coeff ;
					z -> exp = temp1 -> exp ;
					temp1 = temp1 -> link ;
					temp2 = temp2 -> link ;
				}
			}
		}
	}
	while ( temp1 != NULL )
	{
		if ( p == NULL )
		{
			p = new polynode ;
			z = p ;
		}
		else
		{
			z -> link = new polynode ;
			z = z -> link ;
		}
		z -> coeff = temp1 -> coeff ;
		z -> exp = temp1 -> exp ;
		temp1 = temp1 -> link ;
	}
	while ( temp2 != NULL )
	{
		if ( p == NULL )
		{
			p = new polynode ;
			z = p ;
		}
		else
		{
			z -> link = new  polynode ;
			z = z -> link ;
		}
		z -> coeff = temp2 -> coeff ;
		z -> exp = temp2 -> exp ;
		temp2 = temp2 -> link ;
	}
	z -> link = NULL ;
}
poly :: ~poly( )
{
	polynode *q ;
	while ( p != NULL )
	{
		q = p -> link ;
		delete p ;
		p = q ;
	}
}
void main( )
{
	poly p1 ;
	p1.poly_append ( 1.4, 5 ) ;
	p1.poly_append ( 1.5, 4 ) ;
	p1.poly_append ( 1.7, 2 ) ;
	p1.poly_append ( 1.8, 1 ) ;
	p1.poly_append ( 1.9, 0 ) ;
	cout << "\nFirst polynomial:" ;
	p1.display_poly( ) ;
	poly p2 ;
	p2.poly_append ( 1.5, 6 ) ;
	p2.poly_append ( 2.5, 5 ) ;
	p2.poly_append ( -3.5, 4 ) ;
	p2.poly_append ( 4.5, 3 ) ;
	p2.poly_append ( 6.5, 1 ) ;
	cout << "\nSecond polynomial:" ;
	p2.display_poly( ) ;
	poly p3 ;
	p3.poly_add ( p1, p2 ) ;
	cout << "\nResultant polynomial: " ;
	p3.display_poly( ) ;
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-add-two-polynomials-maintained-using-linked-lists/">C++ program to add two polynomials maintained using Linked Lists</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-add-two-polynomials-maintained-using-linked-lists/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
	</channel>
</rss>
