<?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>struct | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/struct/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:52:17 +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 implement stack using Linked List</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-stack-using-linked-list/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-stack-using-linked-list/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 03 Feb 2011 10:50:47 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[struct]]></category>
		<category><![CDATA[Linked Lists]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[stack]]></category>
		<category><![CDATA[C Programs]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1252</guid>

					<description><![CDATA[<p>#include template class Node { friend LinkedStack; private: T data; Node *link; }; template class LinkedStack { public: LinkedStack() {top = 0;} ~LinkedStack(); int IsEmpty() const {return top == 0;} T Top() const; LinkedStack&#038; Add(const T&#038; x); LinkedStack&#038; Delete(T&#038; x); private: Node *top; }; template LinkedStack::~LinkedStack() {// Stack destructor.. Node *next; while (top) { next</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-stack-using-linked-list/">C++ program to implement stack using Linked List</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#include <iostream.h>
template<class T>
class Node
{
	friend LinkedStack<T>;
	private:
	T data;
	Node<T> *link;
};
template<class T>
class LinkedStack {
	public:
		LinkedStack() {top = 0;}
		~LinkedStack();
		int IsEmpty() const {return top == 0;}
		T Top() const;
		LinkedStack<T>& Add(const T& x);
		LinkedStack<T>& Delete(T& x);
	private:
		Node<T> *top; 
};
	template<class T>
LinkedStack<T>::~LinkedStack()
{// Stack destructor..
	Node<T> *next;
	while (top) {
		next = top->link;
		delete top;
		top = next;
	}
}
template<class T>
T LinkedStack<T>::Top() const
{// Return top element.
	if (IsEmpty()) cout<<"Stack empty:";
	else
		return top->data;
}
	template<class T>
LinkedStack<T>& LinkedStack<T>::Add(const T& x)
{// Add x to stack.
	Node<T> *p = new Node<T>;
	p->data = x;
	p->link = top;
	top = p;
	return *this;
}
	template<class T>
LinkedStack<T>& LinkedStack<T>::Delete(T& x)
{// Delete top element and put it in x.
	if (IsEmpty()) 
	{
		cout<<"Stack empty";
		return *this;
	}
	x = top->data;
	Node<T> *p = top;
	top = top->link;
	delete p;
	return *this;
}
void main(void)
{
	int x;
	LinkedStack<int> S;
	S.Add(1).Add(2).Add(3).Add(4);
	cout << "Stack should be 1234" << endl;
	cout << "Stack top is " << S.Top() << endl;
	S.Delete(x);
	cout << "Deleted " << x << endl;
	S.Delete(x);
	cout << "Deleted " << x << endl;
	S.Delete(x);
	cout << "Deleted " << x << endl;
	S.Delete(x);
	cout << "Deleted " << x << endl;
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-stack-using-linked-list/">C++ program to implement stack using Linked List</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-implement-stack-using-linked-list/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>C++ program to implement Stack using Formula Based Representation</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-stack-using-formula-based-representation/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-stack-using-formula-based-representation/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 03 Feb 2011 10:47:47 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[stack]]></category>
		<category><![CDATA[Formula Based Representation]]></category>
		<category><![CDATA[struct]]></category>
		<category><![CDATA[Linked Lists]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[C Programs]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1250</guid>

					<description><![CDATA[<p>#include #include template class Stack { public: Stack(int MaxStackSize); ~Stack(){delete[] S;} int IsEmpty()const{return top==-1;} int IsFull()const{return top==MaxTop;} T Peek()const; void Push(T); T Pop(); void Display(); private: int top; //current top of stack int MaxTop; //max val for top T *S; //element array }; template Stack::Stack(int MaxStackSize) { //stack constructor MaxTop=MaxStackSize-1; S=new T[MaxStackSize]; top=-1; } template</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-stack-using-formula-based-representation/">C++ program to implement Stack using Formula Based Representation</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#include<iostream.h>
#include<constream.h>
template<class T>
class Stack
{
	public:
		Stack(int MaxStackSize);
		~Stack(){delete[] S;}
		int IsEmpty()const{return top==-1;}
		int IsFull()const{return top==MaxTop;}
		T Peek()const;
		void Push(T);
		T Pop();
		void Display();
	private:
		int top; //current top of stack
		int MaxTop; //max val for top
		T *S; //element array
};
	template<class T>
Stack<T>::Stack(int MaxStackSize)
{
	//stack constructor
	MaxTop=MaxStackSize-1;
	S=new T[MaxStackSize];
	top=-1;
}
template<class T>
T Stack<T>::Peek()const
{
	if(IsEmpty()) //top fails
		return 0;
	else
		return S[top];
}
	template<class T>
void Stack<T>::Push(T x)
{
	if(IsFull())
		cout<<"no memory()"; //add fails
	else
	{
		S[++top]=x;
	}
}
	template<class T>
T Stack<T>::Pop()
{
	T x;
	if(IsEmpty())
	{
		cout<<"stack is empty\n";
		return -1;
	}
	else
	{
		x=S[top--];
		return x;
	}
}
	template<class T>
void Stack<T>::Display()
{
	if(IsEmpty())
		cout<<"out of bounds"; //delete fails
	else
		for(int i=top;i>=0;i--)
		{
			cout<<S[i]<<"\t";
		}
}
void menu()
{
	cout<<"1.Push\n 2.Pop\n 3.Peek\n 4.Display\n";
}
void main()
{
	Stack<int>iobj(5);
	int ch,x;
	clrscr();
	do
	{
		menu();
		cout<<"enter the choice\n";
		cin>>ch;
		switch(ch)
		{
			case 1:
				cout<<"enter x value to push into the stack\n";
				cin>>x;
				iobj.Push(x);
				break;
			case 2:
				x=iobj.Pop();
				if(x!=-1)
					cout<<"poped value is \t"<<x<<endl;
				break;
			case 3:
				x=iobj.Peek();
				cout<<"top most value is \t"<<x<<endl;
				break;
			case 4:
				iobj.Display();
				break;
		}
	}while(ch>=1&&ch<=4);
	getch();
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/c-program-to-implement-stack-using-formula-based-representation/">C++ program to implement Stack using Formula Based Representation</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-implement-stack-using-formula-based-representation/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<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[multiply]]></category>
		<category><![CDATA[struct]]></category>
		<category><![CDATA[Linked Lists]]></category>
		<category><![CDATA[polynomials]]></category>
		<category><![CDATA[C Programs]]></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[struct]]></category>
		<category><![CDATA[Linked Lists]]></category>
		<category><![CDATA[polynomials]]></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>
