<?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>bugs of a debugger &#187; C and C++</title>
	<atom:link href="http://arunmvishnu.com/category/programming/c-and-c/feed" rel="self" type="application/rss+xml" />
	<link>http://arunmvishnu.com</link>
	<description>itz all about me, my works, my views, my feelings …. all my bla bla blas</description>
	<lastBuildDate>Thu, 09 Sep 2010 09:55:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>C++ Program for Bubble sort</title>
		<link>http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html</link>
		<comments>http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html#comments</comments>
		<pubDate>Sat, 27 Dec 2008 19:22:12 +0000</pubDate>
		<dc:creator>Arun Vishnu</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[c and cpp]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://arunmvishnu.com/?p=576</guid>
		<description><![CDATA[C++ Program for Bubble sort.

/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program for Bubble sort
***************************************************************/
#include&#38;lt;iostream.h&#38;gt;
#include&#38;lt;conio.h&#38;gt;
void main&#40;&#41;
&#123;
	int array&#91;100&#93;,n,i,j,temp;
	clrscr&#40;&#41;;
	cout&#60;&#60;&#34;How many numbers--&#62; &#34;;
	cin&#62;&#62;n;
	cout&#60;&#60;&#34;Enter &#34;&#60;&#60;n&#60;&#60;&#34; numbers\n&#34;;
	for&#40;i=0;i&#60;n;i++&#41;
		cin&#62;&#62;array&#91;i&#93;;
	for&#40;i=0;i&#60;n;i++&#41;
	&#123;
		for&#40;j=0;j&#60;n-1;j++&#41;
			if&#40;array&#91;j&#93;&#62;array&#91;j+1&#93;&#41;
			&#123;
				temp=array&#91;j&#93;;
				array&#91;j&#93;=array&#91;j+1&#93;;
				array&#91;j+1&#93;=temp;
			&#125;
	&#125;
	cout&#60;&#60;&#34;\nArray is sorted in ascending order.\n&#34;;
	for&#40;i=0;i&#60;n;i++&#41;
		cout&#60;&#60;array&#91;i&#93;&#60;&#60;&#34;   &#34;;
	getch&#40;&#41;;
&#125;






		
			Promote this on Orkut
		
		
			Share this on Facebook
		
		
			Digg this!
		
		
			Share this on del.icio.us
		
		
			Tweet This!
		
		
			Share this on Reddit
		
		
			Buzz up!
		
		
			Stumble upon something good? Share it on StumbleUpon
		
		
			Share this on Technorati
		
		
			Post [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>C++ Program for Bubble sort.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #ff0000; font-style: italic;">/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program for Bubble sort
***************************************************************/</span>
<span style="color: #339900;">#include&amp;lt;iostream.h&amp;gt;</span>
<span style="color: #339900;">#include&amp;lt;conio.h&amp;gt;</span>
<span style="color: #0000ff;">void</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> array<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">100</span><span style="color: #008000;">&#93;</span>,n,i,j,temp<span style="color: #008080;">;</span>
	clrscr<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;How many numbers--&gt; &quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>n<span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Enter &quot;</span><span style="color: #000080;">&lt;&lt;</span>n<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot; numbers<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;</span>n<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
		<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>array<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;</span>n<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>j<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>j<span style="color: #000080;">&lt;</span>n<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>j<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
			<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>array<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #000080;">&gt;</span>array<span style="color: #008000;">&#91;</span>j<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span>
			<span style="color: #008000;">&#123;</span>
				temp<span style="color: #000080;">=</span>array<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
				array<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>array<span style="color: #008000;">&#91;</span>j<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
				array<span style="color: #008000;">&#91;</span>j<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>temp<span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Array is sorted in ascending order.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;</span>n<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
		<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>array<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;   &quot;</span><span style="color: #008080;">;</span>
	getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=C%2B%2B+Program+for+Bubble+sort&amp;du=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html&amp;cn=C%2B%2B%20Program%20for%20Bubble%20sort.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20for%20Bubble%20sort%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%23include%26lt%3Biostream.h%26gt%3B%0D%0A%23include%26lt%3B" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html&amp;t=C%2B%2B+Program+for+Bubble+sort" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html&amp;title=C%2B%2B+Program+for+Bubble+sort" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html&amp;title=C%2B%2B+Program+for+Bubble+sort" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=C%2B%2B+Program+for+Bubble+sort+-+http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html+(via+@arunmvishnu)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html&amp;title=C%2B%2B+Program+for+Bubble+sort" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html&amp;submitHeadline=C%2B%2B+Program+for+Bubble+sort&amp;submitSummary=C%2B%2B%20Program%20for%20Bubble%20sort.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20for%20Bubble%20sort%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%23include%26lt%3Biostream.h%26gt%3B%0D%0A%23include%26lt%3B&amp;submitCategory=science&amp;submitAssetType=image" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html&amp;title=C%2B%2B+Program+for+Bubble+sort" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-myspace">
			<a href="http://www.myspace.com/Modules/PostTo/Pages/?u=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html&amp;t=C%2B%2B+Program+for+Bubble+sort" rel="nofollow" title="Post this to MySpace">Post this to MySpace</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html&amp;title=C%2B%2B+Program+for+Bubble+sort&amp;summary=C%2B%2B%20Program%20for%20Bubble%20sort.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20for%20Bubble%20sort%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%23include%26lt%3Biostream.h%26gt%3B%0D%0A%23include%26lt%3B&amp;source=bugs of a debugger" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html&amp;title=C%2B%2B+Program+for+Bubble+sort" rel="nofollow" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=C%2B%2B+Program+for+Bubble+sort&amp;link=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html&amp;t=C%2B%2B+Program+for+Bubble+sort" rel="nofollow" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="sexy-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html&amp;title=C%2B%2B+Program+for+Bubble+sort" rel="nofollow" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="sexy-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html&amp;title=C%2B%2B+Program+for+Bubble+sort" rel="nofollow" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html&amp;n=C%2B%2B+Program+for+Bubble+sort&amp;pli=1" rel="nofollow" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Farunmvishnu.com%2Fprogramming%2Fc-and-c%2Fc-program-for-bubble-sort.html&amp;linkname=C%2B%2B%20Program%20for%20Bubble%20sort"><img src="http://arunmvishnu.com/home/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://arunmvishnu.com/programming/c-and-c/c-program-for-bubble-sort.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>C++ Program Program for Binary Search.</title>
		<link>http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html</link>
		<comments>http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html#comments</comments>
		<pubDate>Sat, 27 Dec 2008 19:19:51 +0000</pubDate>
		<dc:creator>Arun Vishnu</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[c and cpp]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://arunmvishnu.com/?p=574</guid>
		<description><![CDATA[C++ Program Program for Binary Search.

/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program Program for Binary Search.
***************************************************************/
#include&#38;lt;iostream.h&#38;gt;
#include&#38;lt;conio.h&#38;gt;
#include&#38;lt;process.h&#38;gt;
void main&#40;&#41;
&#123;
	int ar&#91;100&#93;,beg,mid,end,i,n,search;
	clrscr&#40;&#41;;
	cout&#60;&#60;&#34;How many numbers in the array: &#34;;
	cin&#62;&#62;n;
	cout&#60;&#60;&#34;Enter &#34;&#60;&#60;n&#60;&#60;&#34; numbers in ascending order --&#62; &#34;;
	for&#40;i=0;i&#60;n;i++&#41;
		cin&#62;&#62;ar&#91;i&#93;;
	beg=0;
	end=n-1;
	cout&#60;&#60;&#34;Enter a number to search: &#34;;
	cin&#62;&#62;search;
	while&#40;beg&#60;=end&#41;
	&#123;
		mid=&#40;beg+end&#41;/2;
		if&#40;ar&#91;mid&#93;==search&#41;
		&#123;
			cout&#60;&#60;&#34;\nItem found at position &#34;&#60;&#60;&#40;mid+1&#41;;
			getch&#40;&#41;;
			exit&#40;0&#41;;
		&#125;
		if&#40;search&#62;ar&#91;mid&#93;&#41;
			beg=mid+1;
		else
			end=mid-1;
	&#125;
	cout&#60;&#60;&#34;\nSorry! &#34;&#60;&#60;search&#60;&#60;&#34; doesnot found.&#34;;
	getch&#40;&#41;;
&#125;






		
			Promote this on Orkut
		
		
			Share this on Facebook
		
		
			Digg this!
		
		
			Share this on del.icio.us
		
		
			Tweet This!
		
		
			Share [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>C++ Program Program for Binary Search.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #ff0000; font-style: italic;">/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program Program for Binary Search.
***************************************************************/</span>
<span style="color: #339900;">#include&amp;lt;iostream.h&amp;gt;</span>
<span style="color: #339900;">#include&amp;lt;conio.h&amp;gt;</span>
<span style="color: #339900;">#include&amp;lt;process.h&amp;gt;</span>
<span style="color: #0000ff;">void</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> ar<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">100</span><span style="color: #008000;">&#93;</span>,beg,mid,end,i,n,search<span style="color: #008080;">;</span>
	clrscr<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;How many numbers in the array: &quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>n<span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Enter &quot;</span><span style="color: #000080;">&lt;&lt;</span>n<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot; numbers in ascending order --&gt; &quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;</span>n<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
		<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>ar<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	beg<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
	end<span style="color: #000080;">=</span>n<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Enter a number to search: &quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>search<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span>beg<span style="color: #000080;">&lt;=</span>end<span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		mid<span style="color: #000080;">=</span><span style="color: #008000;">&#40;</span>beg<span style="color: #000040;">+</span>end<span style="color: #008000;">&#41;</span><span style="color: #000040;">/</span><span style="color: #0000dd;">2</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>ar<span style="color: #008000;">&#91;</span>mid<span style="color: #008000;">&#93;</span><span style="color: #000080;">==</span>search<span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
			<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Item found at position &quot;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #008000;">&#40;</span>mid<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			<span style="color: #0000dd;">exit</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>search<span style="color: #000080;">&gt;</span>ar<span style="color: #008000;">&#91;</span>mid<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span>
			beg<span style="color: #000080;">=</span>mid<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">else</span>
			end<span style="color: #000080;">=</span>mid<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Sorry! &quot;</span><span style="color: #000080;">&lt;&lt;</span>search<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot; doesnot found.&quot;</span><span style="color: #008080;">;</span>
	getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=C%2B%2B+Program+Program+for+Binary+Search.&amp;du=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html&amp;cn=C%2B%2B%20Program%20Program%20for%20Binary%20Search.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20Program%20for%20Binary%20Search.%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%23include%26lt%3Biostrea" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html&amp;t=C%2B%2B+Program+Program+for+Binary+Search." rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html&amp;title=C%2B%2B+Program+Program+for+Binary+Search." rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html&amp;title=C%2B%2B+Program+Program+for+Binary+Search." rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=C%2B%2B+Program+Program+for+Binary+Search.+-+http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html+(via+@arunmvishnu)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html&amp;title=C%2B%2B+Program+Program+for+Binary+Search." rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html&amp;submitHeadline=C%2B%2B+Program+Program+for+Binary+Search.&amp;submitSummary=C%2B%2B%20Program%20Program%20for%20Binary%20Search.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20Program%20for%20Binary%20Search.%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%23include%26lt%3Biostrea&amp;submitCategory=science&amp;submitAssetType=image" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html&amp;title=C%2B%2B+Program+Program+for+Binary+Search." rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-myspace">
			<a href="http://www.myspace.com/Modules/PostTo/Pages/?u=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html&amp;t=C%2B%2B+Program+Program+for+Binary+Search." rel="nofollow" title="Post this to MySpace">Post this to MySpace</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html&amp;title=C%2B%2B+Program+Program+for+Binary+Search.&amp;summary=C%2B%2B%20Program%20Program%20for%20Binary%20Search.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20Program%20for%20Binary%20Search.%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%23include%26lt%3Biostrea&amp;source=bugs of a debugger" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html&amp;title=C%2B%2B+Program+Program+for+Binary+Search." rel="nofollow" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=C%2B%2B+Program+Program+for+Binary+Search.&amp;link=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html&amp;t=C%2B%2B+Program+Program+for+Binary+Search." rel="nofollow" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="sexy-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html&amp;title=C%2B%2B+Program+Program+for+Binary+Search." rel="nofollow" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="sexy-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html&amp;title=C%2B%2B+Program+Program+for+Binary+Search." rel="nofollow" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html&amp;n=C%2B%2B+Program+Program+for+Binary+Search.&amp;pli=1" rel="nofollow" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Farunmvishnu.com%2Fprogramming%2Fc-and-c%2Fc-program-program-for-binary-search.html&amp;linkname=C%2B%2B%20Program%20Program%20for%20Binary%20Search."><img src="http://arunmvishnu.com/home/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://arunmvishnu.com/programming/c-and-c/c-program-program-for-binary-search.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>C++ Program to implement a stack using linked list</title>
		<link>http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html</link>
		<comments>http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html#comments</comments>
		<pubDate>Thu, 27 Nov 2008 20:09:58 +0000</pubDate>
		<dc:creator>Arun Vishnu</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[c and cpp]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://arunmvishnu.com/?p=620</guid>
		<description><![CDATA[C++ Program to implement a stack using linked list.

/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program to implement a stack using linked list.
***************************************************************/
#include&#38;lt;conio.h&#38;gt;   	
#include&#38;lt;iostream.h&#38;gt; 
#include&#38;lt;process.h&#38;gt;  
#include&#38;lt;malloc.h&#38;gt;  
&#160;
&#160;
//   Creating a NODE Structure
struct node
&#123;
   int data;
   struct node *next;
&#125;;
&#160;
// Creating a class STACK
class stack
&#123;
   struct [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>C++ Program to implement a stack using linked list.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #ff0000; font-style: italic;">/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program to implement a stack using linked list.
***************************************************************/</span>
<span style="color: #339900;">#include&amp;lt;conio.h&amp;gt;   	</span>
<span style="color: #339900;">#include&amp;lt;iostream.h&amp;gt; </span>
<span style="color: #339900;">#include&amp;lt;process.h&amp;gt;  </span>
<span style="color: #339900;">#include&amp;lt;malloc.h&amp;gt;  </span>
&nbsp;
&nbsp;
<span style="color: #666666;">//   Creating a NODE Structure</span>
<span style="color: #0000ff;">struct</span> node
<span style="color: #008000;">&#123;</span>
   <span style="color: #0000ff;">int</span> data<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>next<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #666666;">// Creating a class STACK</span>
<span style="color: #0000ff;">class</span> stack
<span style="color: #008000;">&#123;</span>
   <span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>top<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
      stack<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #666666;">// constructure</span>
      <span style="color: #008000;">&#123;</span>
	 top<span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
      <span style="color: #008000;">&#125;</span>
      <span style="color: #0000ff;">void</span> push<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// to insert an element</span>
      <span style="color: #0000ff;">void</span> pop<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>  <span style="color: #666666;">// to delete an element</span>
      <span style="color: #0000ff;">void</span> show<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// to show the stack</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
<span style="color: #666666;">// PUSH Operation</span>
<span style="color: #0000ff;">void</span> stack<span style="color: #008080;">::</span><span style="color: #007788;">push</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   <span style="color: #0000ff;">int</span> value<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>ptr<span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>PUSH Operation<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Enter a number to insert: &quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>value<span style="color: #008080;">;</span>
   ptr<span style="color: #000080;">=</span><span style="color: #0000dd;">new</span> node<span style="color: #008080;">;</span>
   ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #000080;">=</span>value<span style="color: #008080;">;</span>
   ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>top<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span>
      ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">=</span>top<span style="color: #008080;">;</span>
   top<span style="color: #000080;">=</span>ptr<span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>New item is inserted to the stack!!!&quot;</span><span style="color: #008080;">;</span>
   getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #666666;">// POP Operation</span>
<span style="color: #0000ff;">void</span> stack<span style="color: #008080;">::</span><span style="color: #007788;">pop</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   <span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>temp<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>top<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>The stack is empty!!!&quot;</span><span style="color: #008080;">;</span>
      getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
      <span style="color: #0000ff;">return</span><span style="color: #008080;">;</span>
   <span style="color: #008000;">&#125;</span>
   temp<span style="color: #000080;">=</span>top<span style="color: #008080;">;</span>
   top<span style="color: #000080;">=</span>top<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>POP Operation........<span style="color: #000099; font-weight: bold;">\n</span>Poped value is &quot;</span><span style="color: #000080;">&lt;&lt;</span>temp<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #008080;">;</span>
   <span style="color: #0000dd;">delete</span> temp<span style="color: #008080;">;</span>
   getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #666666;">// Show stack</span>
<span style="color: #0000ff;">void</span> stack<span style="color: #008080;">::</span><span style="color: #007788;">show</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   <span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>ptr1<span style="color: #000080;">=</span>top<span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>The stack is<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span>ptr1<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>ptr1<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot; -&gt;&quot;</span><span style="color: #008080;">;</span>
      ptr1<span style="color: #000080;">=</span>ptr1<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
   <span style="color: #008000;">&#125;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;NULL<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #666666;">// Main function</span>
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   clrscr<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
   stack s<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">int</span> choice<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>-----------------------------------------------------------&quot;</span><span style="color: #008080;">;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>STACK USING LINKED LIST<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;1:PUSH<span style="color: #000099; font-weight: bold;">\n</span>2:POP<span style="color: #000099; font-weight: bold;">\n</span>3:DISPLAY STACK<span style="color: #000099; font-weight: bold;">\n</span>4:EXIT&quot;</span><span style="color: #008080;">;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Enter your choice(1-4): &quot;</span><span style="color: #008080;">;</span>
      <span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>choice<span style="color: #008080;">;</span>
      <span style="color: #0000ff;">switch</span><span style="color: #008000;">&#40;</span>choice<span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
       <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">:</span>
	  s.<span style="color: #007788;">push</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	  <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
       <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">2</span><span style="color: #008080;">:</span>
	  s.<span style="color: #007788;">pop</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	  <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
       <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">3</span><span style="color: #008080;">:</span>
	  s.<span style="color: #007788;">show</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	  <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
       <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">4</span><span style="color: #008080;">:</span>
	  <span style="color: #0000dd;">exit</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	  <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
       <span style="color: #0000ff;">default</span><span style="color: #008080;">:</span>
	  <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Please enter correct choice(1-4)!!&quot;</span><span style="color: #008080;">;</span>
	  getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	  <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
       <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
   <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #666666;">//---------------------- END--------------------</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=C%2B%2B+Program+to+implement+a+stack+using+linked+list&amp;du=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html&amp;cn=C%2B%2B%20Program%20to%20implement%20a%20stack%20using%20linked%20list.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20to%20implement%20a%20stack%20using%20linked%20list.%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html&amp;t=C%2B%2B+Program+to+implement+a+stack+using+linked+list" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+stack+using+linked+list" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+stack+using+linked+list" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=C%2B%2B+Program+to+implement+a+stack+using+linked+list+-+http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html+(via+@arunmvishnu)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+stack+using+linked+list" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html&amp;submitHeadline=C%2B%2B+Program+to+implement+a+stack+using+linked+list&amp;submitSummary=C%2B%2B%20Program%20to%20implement%20a%20stack%20using%20linked%20list.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20to%20implement%20a%20stack%20using%20linked%20list.%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A&amp;submitCategory=science&amp;submitAssetType=image" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+stack+using+linked+list" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-myspace">
			<a href="http://www.myspace.com/Modules/PostTo/Pages/?u=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html&amp;t=C%2B%2B+Program+to+implement+a+stack+using+linked+list" rel="nofollow" title="Post this to MySpace">Post this to MySpace</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+stack+using+linked+list&amp;summary=C%2B%2B%20Program%20to%20implement%20a%20stack%20using%20linked%20list.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20to%20implement%20a%20stack%20using%20linked%20list.%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A&amp;source=bugs of a debugger" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+stack+using+linked+list" rel="nofollow" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=C%2B%2B+Program+to+implement+a+stack+using+linked+list&amp;link=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html&amp;t=C%2B%2B+Program+to+implement+a+stack+using+linked+list" rel="nofollow" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="sexy-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+stack+using+linked+list" rel="nofollow" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="sexy-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+stack+using+linked+list" rel="nofollow" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html&amp;n=C%2B%2B+Program+to+implement+a+stack+using+linked+list&amp;pli=1" rel="nofollow" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Farunmvishnu.com%2Fprogramming%2Fc-and-c%2Fc-program-to-implement-a-stack-using-linked-list.html&amp;linkname=C%2B%2B%20Program%20to%20implement%20a%20stack%20using%20linked%20list"><img src="http://arunmvishnu.com/home/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-stack-using-linked-list.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>C++ Program implement a stack using an array</title>
		<link>http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html</link>
		<comments>http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html#comments</comments>
		<pubDate>Thu, 27 Nov 2008 20:06:00 +0000</pubDate>
		<dc:creator>Arun Vishnu</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[c and cpp]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://arunmvishnu.com/?p=616</guid>
		<description><![CDATA[C++ Program implement a stack using an array.

/**************************************************************
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program implement a stack using an array
***************************************************************/
#include&#60;conio.h&#62;
#include&#60;iostream.h&#62;
#include&#60;process.h&#62;  

void main()
{
	int stack[150],top,n,i,max_stack,choice,element,n_pop;
	max_stack=150;
	coutn;
	cout



No related posts.


No related posts.]]></description>
			<content:encoded><![CDATA[<p>C++ Program implement a stack using an array.</p>
<pre>
/**************************************************************
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program implement a stack using an array
***************************************************************/
#include&lt;conio.h&gt;
#include&lt;iostream.h&gt;
#include&lt;process.h&gt;  

void main()
{
	int stack[150],top,n,i,max_stack,choice,element,n_pop;
	max_stack=150;
	cout<<"How many elements are in the stack: ";
	cin>>n;
	cout<<"Enter "<<n<<" elements.\n";
	for(top=0;top<n;top++)
		cin>>stack[top];
	cout<<"\nStack is implemented.\nThe stack is\n";
	for(i=top-1;i>=0;i--)
		cout<<stack[i]<<"   ";
	getch();
	while(1)
	{
		clrscr();
		cout<<"1: PUSH\n2: POP\n3: Display Stack\n4: Exit\nEnter your choice: ";
		cin>>choice;
		switch(choice)
		{
			case 1:     //  PUSH
				cout<<"\nPUSH OPERATION\n";
				if(top>=max_stack)
            {
					cout<<"Stack is full!";
					getch();
					break;
				}
				cout<<"Enter an element: ";
				cin>>element;
				stack[top]=element;
            top++;
				cout<<"Item Inserted!";
				getch();
				break;
			case 2:             // POP
				cout<<"POP OPERATION\n";
				if(top<0)
				{
					cout<<"Stack is empty";
					getch();
					break;
				}
				cout<<"How many elements you want to pop: ";
            cin>>n_pop;
				if(n_pop>top)
				{
					cout<<"\nError!\nStack is small.";
					getch();
               break;
				}
				top=top-n_pop;
				cout<<"Items POPed";
				getch();
				break;
			case 3:       //  Display
				cout<<"\The stack is\n";
				for(i=top-1;i>=0;i--)
					cout<<stack[i]<<"   ";
				getch();
				break;
			case 4:
				exit(0);
				getch();
			default:
				cout<<"RE-enter your choice!";
		}	// End of switch
	}		// End of while
	getch();
}

//---------------------- END--------------------
</pre>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=C%2B%2B+Program+implement+a+stack+using+an+array&amp;du=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html&amp;cn=C%2B%2B%20Program%20implement%20a%20stack%20using%20an%20array.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20implement%20a%20stack%20using%20an%20array%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%23inclu" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html&amp;t=C%2B%2B+Program+implement+a+stack+using+an+array" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html&amp;title=C%2B%2B+Program+implement+a+stack+using+an+array" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html&amp;title=C%2B%2B+Program+implement+a+stack+using+an+array" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=C%2B%2B+Program+implement+a+stack+using+an+array+-+http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html+(via+@arunmvishnu)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html&amp;title=C%2B%2B+Program+implement+a+stack+using+an+array" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html&amp;submitHeadline=C%2B%2B+Program+implement+a+stack+using+an+array&amp;submitSummary=C%2B%2B%20Program%20implement%20a%20stack%20using%20an%20array.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20implement%20a%20stack%20using%20an%20array%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%23inclu&amp;submitCategory=science&amp;submitAssetType=image" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html&amp;title=C%2B%2B+Program+implement+a+stack+using+an+array" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-myspace">
			<a href="http://www.myspace.com/Modules/PostTo/Pages/?u=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html&amp;t=C%2B%2B+Program+implement+a+stack+using+an+array" rel="nofollow" title="Post this to MySpace">Post this to MySpace</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html&amp;title=C%2B%2B+Program+implement+a+stack+using+an+array&amp;summary=C%2B%2B%20Program%20implement%20a%20stack%20using%20an%20array.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20implement%20a%20stack%20using%20an%20array%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%23inclu&amp;source=bugs of a debugger" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html&amp;title=C%2B%2B+Program+implement+a+stack+using+an+array" rel="nofollow" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=C%2B%2B+Program+implement+a+stack+using+an+array&amp;link=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html&amp;t=C%2B%2B+Program+implement+a+stack+using+an+array" rel="nofollow" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="sexy-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html&amp;title=C%2B%2B+Program+implement+a+stack+using+an+array" rel="nofollow" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="sexy-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html&amp;title=C%2B%2B+Program+implement+a+stack+using+an+array" rel="nofollow" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html&amp;n=C%2B%2B+Program+implement+a+stack+using+an+array&amp;pli=1" rel="nofollow" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Farunmvishnu.com%2Fprogramming%2Fc-and-c%2Fimplement-a-stack-using-an-array.html&amp;linkname=C%2B%2B%20Program%20implement%20a%20stack%20using%20an%20array"><img src="http://arunmvishnu.com/home/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://arunmvishnu.com/programming/c-and-c/implement-a-stack-using-an-array.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>C++ Program to add and subtract 2 sparse matrices</title>
		<link>http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html</link>
		<comments>http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html#comments</comments>
		<pubDate>Thu, 27 Nov 2008 20:04:16 +0000</pubDate>
		<dc:creator>Arun Vishnu</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[c and cpp]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://arunmvishnu.com/?p=614</guid>
		<description><![CDATA[C++ Program to add and subtract 2 sparse matrices.

/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program to add and subtract 2 sparse matrices
***************************************************************/
#include&#38;lt;conio.h&#38;gt;   	
#include&#38;lt;iostream.h&#38;gt; 
#include&#38;lt;process.h&#38;gt;  
&#160;
int main&#40;&#41;
&#123;
   clrscr&#40;&#41;;
   int sparse1&#91;10&#93;&#91;3&#93;,sparse2&#91;10&#93;&#91;3&#93;,sum&#91;10&#93;&#91;3&#93;,diff&#91;10&#93;&#91;3&#93;;
   int m,n,p,q,t1,t2,s,d,element;
   int i,j;
   cout&#60;&#60;&#34;Enter the number of rows and columns : [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>C++ Program to add and subtract 2 sparse matrices.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #ff0000; font-style: italic;">/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program to add and subtract 2 sparse matrices
***************************************************************/</span>
<span style="color: #339900;">#include&amp;lt;conio.h&amp;gt;   	</span>
<span style="color: #339900;">#include&amp;lt;iostream.h&amp;gt; </span>
<span style="color: #339900;">#include&amp;lt;process.h&amp;gt;  </span>
&nbsp;
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   clrscr<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">int</span> sparse1<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">10</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span>,sparse2<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">10</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span>,sum<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">10</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span>,diff<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">10</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">int</span> m,n,p,q,t1,t2,s,d,element<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">int</span> i,j<span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Enter the number of rows and columns : &quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>m<span style="color: #000080;">&gt;&gt;</span>n<span style="color: #008080;">;</span>
   t1<span style="color: #000080;">=</span>t2<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
&nbsp;
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Enter the first matrix(&quot;</span><span style="color: #000080;">&lt;&lt;</span>m<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;*&quot;</span><span style="color: #000080;">&lt;&lt;</span>n<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;):<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;=</span>m<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>j<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>j<span style="color: #000080;">&lt;=</span>n<span style="color: #008080;">;</span>j<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
	 <span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>element<span style="color: #008080;">;</span>
	 <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>element<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span>
	 <span style="color: #008000;">&#123;</span>
	    t1<span style="color: #000080;">=</span>t1<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	    sparse1<span style="color: #008000;">&#91;</span>t1<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>i<span style="color: #008080;">;</span>
	    sparse1<span style="color: #008000;">&#91;</span>t1<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>j<span style="color: #008080;">;</span>
	    sparse1<span style="color: #008000;">&#91;</span>t1<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>element<span style="color: #008080;">;</span>
	 <span style="color: #008000;">&#125;</span>
      <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
   sparse1<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>m<span style="color: #008080;">;</span>
   sparse1<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>n<span style="color: #008080;">;</span>
   sparse1<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>t1<span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Enter the second matrix(&quot;</span><span style="color: #000080;">&lt;&lt;</span>m<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;*&quot;</span><span style="color: #000080;">&lt;&lt;</span>n<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;):<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;=</span>m<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>j<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>j<span style="color: #000080;">&lt;=</span>n<span style="color: #008080;">;</span>j<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
	 <span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>element<span style="color: #008080;">;</span>
	 <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>element<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span>
	 <span style="color: #008000;">&#123;</span>
	    t2<span style="color: #000080;">=</span>t2<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	    sparse2<span style="color: #008000;">&#91;</span>t2<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>i<span style="color: #008080;">;</span>
	    sparse2<span style="color: #008000;">&#91;</span>t2<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>j<span style="color: #008080;">;</span>
	    sparse2<span style="color: #008000;">&#91;</span>t2<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>element<span style="color: #008080;">;</span>
	 <span style="color: #008000;">&#125;</span>
      <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
   sparse2<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>m<span style="color: #008080;">;</span>
   sparse2<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>n<span style="color: #008080;">;</span>
   sparse2<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>t2<span style="color: #008080;">;</span>
&nbsp;
   <span style="color: #666666;">// displaying the first sparse matrix</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>The first sparse matrix is :<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>Row<span style="color: #000099; font-weight: bold;">\t</span>Column<span style="color: #000099; font-weight: bold;">\t</span>Element&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>-----------------------<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;=</span>t1<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #008000;">&#125;</span>
    <span style="color: #666666;">// displaying the second sparse matrix</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>The second sparse matrix is :<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>Row<span style="color: #000099; font-weight: bold;">\t</span>Column<span style="color: #000099; font-weight: bold;">\t</span>Element&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>-----------------------<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;=</span>t2<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>sparse2<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>sparse2<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>sparse2<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #008000;">&#125;</span>
&nbsp;
   <span style="color: #666666;">// Addition and subtraction</span>
   i<span style="color: #000080;">=</span>j<span style="color: #000080;">=</span>s<span style="color: #000080;">=</span>d<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">&lt;=</span>t1<span style="color: #008000;">&#41;</span><span style="color: #000040;">&amp;&amp;</span><span style="color: #008000;">&#40;</span>j<span style="color: #000080;">&lt;=</span>t2<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">==</span>sparse2<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span>    <span style="color: #666666;">// if rows are equal</span>
      <span style="color: #008000;">&#123;</span>
	 <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">==</span>sparse2<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span> <span style="color: #666666;">// if columns are equal</span>
	 <span style="color: #008000;">&#123;</span>
	    sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	    sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	    sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000040;">+</span>sparse2<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	    diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000040;">-</span>sparse2<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	    i<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	    j<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	    <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span>
	       s<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	    <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span>
	       d<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	 <span style="color: #008000;">&#125;</span>
	 <span style="color: #0000ff;">else</span>   <span style="color: #666666;">// if columns are not equal</span>
	 <span style="color: #008000;">&#123;</span>
	    <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;</span>sparse2<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span>
	    <span style="color: #008000;">&#123;</span>
	       sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	       sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	       sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	       i<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	       s<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	       d<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	    <span style="color: #008000;">&#125;</span>
	    <span style="color: #0000ff;">else</span>
	    <span style="color: #008000;">&#123;</span>
	       sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse2<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	       sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse2<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	       sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse2<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	       diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #000040;">-</span>sparse2<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	       j<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	       d<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	       s<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	    <span style="color: #008000;">&#125;</span>
	 <span style="color: #008000;">&#125;</span>
      <span style="color: #008000;">&#125;</span>
      <span style="color: #0000ff;">else</span>   <span style="color: #666666;">//   if rows are not equal</span>
      <span style="color: #008000;">&#123;</span>
	 <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;</span>sparse2<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span>
	 <span style="color: #008000;">&#123;</span>
	    sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	    sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	    sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse1<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	    i<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	    d<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	    s<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	 <span style="color: #008000;">&#125;</span>
	 <span style="color: #0000ff;">else</span>
	 <span style="color: #008000;">&#123;</span>
	    sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse2<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	    sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse2<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	    sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse2<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	    diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #000040;">-</span>sparse2<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	    j<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	    s<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	    d<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	 <span style="color: #008000;">&#125;</span>
      <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>  <span style="color: #666666;">// end of while</span>
   <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">&lt;=</span>t1<span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>p<span style="color: #000080;">=</span>i<span style="color: #008080;">;</span>p<span style="color: #000080;">&lt;=</span>t1<span style="color: #008080;">;</span>p<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
	 sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse1<span style="color: #008000;">&#91;</span>p<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	 sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse1<span style="color: #008000;">&#91;</span>p<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	 sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse1<span style="color: #008000;">&#91;</span>p<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	 s<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	 d<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
      <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
   <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>j<span style="color: #000080;">&lt;=</span>t2<span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>p<span style="color: #000080;">=</span>j<span style="color: #008080;">;</span>p<span style="color: #000080;">&lt;=</span>t2<span style="color: #008080;">;</span>p<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
	 sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse2<span style="color: #008000;">&#91;</span>p<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	 sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse2<span style="color: #008000;">&#91;</span>p<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	 sum<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse2<span style="color: #008000;">&#91;</span>p<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	 diff<span style="color: #008000;">&#91;</span>d<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #000040;">-</span>sparse2<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	 s<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
	 d<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
      <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
  <span style="color: #666666;">// end of addition and subtraction</span>
  sum<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>m<span style="color: #008080;">;</span>
  sum<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>diff<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>n<span style="color: #008080;">;</span>
  sum<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>s<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
  diff<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>d<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
&nbsp;
  <span style="color: #666666;">// displaying the sum matrix</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>The sum is :<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>Row<span style="color: #000099; font-weight: bold;">\t</span>Column<span style="color: #000099; font-weight: bold;">\t</span>Element&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>-----------------------<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;</span>s<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>sum<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>sum<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>sum<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #008000;">&#125;</span>
    <span style="color: #666666;">// displaying the difference matrix</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>The difference is :<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>Row<span style="color: #000099; font-weight: bold;">\t</span>Column<span style="color: #000099; font-weight: bold;">\t</span>Element&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>-----------------------<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;</span>d<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>diff<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>diff<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>diff<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #008000;">&#125;</span>
   getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #666666;">//---------------------- END--------------------</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices&amp;du=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html&amp;cn=C%2B%2B%20Program%20to%20add%20and%20subtract%202%20sparse%20matrices.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20to%20add%20and%20subtract%202%20sparse%20matrices%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html&amp;t=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html&amp;title=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html&amp;title=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices+-+http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html+(via+@arunmvishnu)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html&amp;title=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html&amp;submitHeadline=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices&amp;submitSummary=C%2B%2B%20Program%20to%20add%20and%20subtract%202%20sparse%20matrices.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20to%20add%20and%20subtract%202%20sparse%20matrices%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A&amp;submitCategory=science&amp;submitAssetType=image" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html&amp;title=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-myspace">
			<a href="http://www.myspace.com/Modules/PostTo/Pages/?u=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html&amp;t=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices" rel="nofollow" title="Post this to MySpace">Post this to MySpace</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html&amp;title=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices&amp;summary=C%2B%2B%20Program%20to%20add%20and%20subtract%202%20sparse%20matrices.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20to%20add%20and%20subtract%202%20sparse%20matrices%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A&amp;source=bugs of a debugger" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html&amp;title=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices" rel="nofollow" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices&amp;link=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html&amp;t=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices" rel="nofollow" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="sexy-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html&amp;title=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices" rel="nofollow" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="sexy-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html&amp;title=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices" rel="nofollow" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html&amp;n=C%2B%2B+Program+to+add+and+subtract+2+sparse+matrices&amp;pli=1" rel="nofollow" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Farunmvishnu.com%2Fprogramming%2Fc-and-c%2Fc-program-to-add-and-subtract-2-sparse-matrices.html&amp;linkname=C%2B%2B%20Program%20to%20add%20and%20subtract%202%20sparse%20matrices"><img src="http://arunmvishnu.com/home/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://arunmvishnu.com/programming/c-and-c/c-program-to-add-and-subtract-2-sparse-matrices.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C++ Program to find the transpose of a Sparse matrix</title>
		<link>http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html</link>
		<comments>http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html#comments</comments>
		<pubDate>Thu, 27 Nov 2008 20:02:37 +0000</pubDate>
		<dc:creator>Arun Vishnu</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[c and cpp]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://arunmvishnu.com/?p=611</guid>
		<description><![CDATA[C++ Program to find the transpose of a Sparse matrix.

/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program to find the transpose of a Sparse matrix 
***************************************************************/
#include&#60;conio.h?  	
#include&#60;iostream.h? 
#include&#60;process.h?  
&#160;
void main&#40;&#41;
&#123;
   clrscr&#40;&#41;;
   int sparse&#91;10&#93;&#91;10&#93;,transpose&#91;10&#93;&#91;10&#93;;
   int m,n,p,q,t,col,element;
   int i,j;
   cout&#60;&#60;&#34;Enter the number of rows and [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>C++ Program to find the transpose of a Sparse matrix.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #ff0000; font-style: italic;">/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program to find the transpose of a Sparse matrix 
***************************************************************/</span>
<span style="color: #339900;">#include&lt;conio.h?  	</span>
<span style="color: #339900;">#include&lt;iostream.h? </span>
<span style="color: #339900;">#include&lt;process.h?  </span>
&nbsp;
<span style="color: #0000ff;">void</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   clrscr<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">int</span> sparse<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">10</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">10</span><span style="color: #008000;">&#93;</span>,transpose<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">10</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">10</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">int</span> m,n,p,q,t,col,element<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">int</span> i,j<span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Enter the number of rows and columns : &quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>m<span style="color: #000080;">&gt;&gt;</span>n<span style="color: #008080;">;</span>
   t<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
	<span style="color: #666666;">// assigning the value of matrix</span>
&nbsp;
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Enter the matrix:<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;=</span>m<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>j<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>j<span style="color: #000080;">&lt;=</span>n<span style="color: #008080;">;</span>j<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
	 <span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>element<span style="color: #008080;">;</span>
	 <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>element<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span>
	 <span style="color: #008000;">&#123;</span>
	    t<span style="color: #000080;">=</span>t<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	    sparse<span style="color: #008000;">&#91;</span>t<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>i<span style="color: #008080;">;</span>
	    sparse<span style="color: #008000;">&#91;</span>t<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>j<span style="color: #008080;">;</span>
	    sparse<span style="color: #008000;">&#91;</span>t<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>element<span style="color: #008080;">;</span>
	 <span style="color: #008000;">&#125;</span>
      <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>The sparse matrix is :<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>Row<span style="color: #000099; font-weight: bold;">\t</span>Column<span style="color: #000099; font-weight: bold;">\t</span>Element&quot;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #666666;">// displaying the matrix of non-zero value</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>m<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>n<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>t<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;=</span>t<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>sparse<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>sparse<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>sparse<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #008000;">&#125;</span>
   sparse<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>n<span style="color: #008080;">;</span> sparse<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>m<span style="color: #008080;">;</span> sparse<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>t<span style="color: #008080;">;</span>
   q<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #666666;">// transpose of the matrix</span>
   <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>t<span style="color: #000080;">&gt;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;=</span>n<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
	 <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>j<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>j<span style="color: #000080;">&lt;=</span>t<span style="color: #008080;">;</span>j<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
	 <span style="color: #008000;">&#123;</span>
	    <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>sparse<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">==</span>i<span style="color: #008000;">&#41;</span>
	    <span style="color: #008000;">&#123;</span>
		transpose<span style="color: #008000;">&#91;</span>q<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
		transpose<span style="color: #008000;">&#91;</span>q<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
		transpose<span style="color: #008000;">&#91;</span>q<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>sparse<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
		q<span style="color: #000080;">=</span>q<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	    <span style="color: #008000;">&#125;</span>
	 <span style="color: #008000;">&#125;</span>
      <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
&nbsp;
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>The transpose of the sparse matrix :<span style="color: #000099; font-weight: bold;">\n</span> &quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Row<span style="color: #000099; font-weight: bold;">\t</span>Column<span style="color: #000099; font-weight: bold;">\t</span>Element<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>sparse<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>sparse<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>sparse<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;=</span>t<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>transpose<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>transpose<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #000080;">&lt;&lt;</span>transpose<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #008000;">&#125;</span>
   getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #666666;">//---------------------- END--------------------</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix&amp;du=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html&amp;cn=C%2B%2B%20Program%20to%20find%20the%20transpose%20of%20a%20Sparse%20matrix.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20to%20find%20the%20transpose%20of%20a%20Sparse%20matrix%20%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html&amp;t=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html&amp;title=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html&amp;title=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix+-+http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html+(via+@arunmvishnu)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html&amp;title=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html&amp;submitHeadline=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix&amp;submitSummary=C%2B%2B%20Program%20to%20find%20the%20transpose%20of%20a%20Sparse%20matrix.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20to%20find%20the%20transpose%20of%20a%20Sparse%20matrix%20%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A&amp;submitCategory=science&amp;submitAssetType=image" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html&amp;title=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-myspace">
			<a href="http://www.myspace.com/Modules/PostTo/Pages/?u=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html&amp;t=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix" rel="nofollow" title="Post this to MySpace">Post this to MySpace</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html&amp;title=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix&amp;summary=C%2B%2B%20Program%20to%20find%20the%20transpose%20of%20a%20Sparse%20matrix.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20to%20find%20the%20transpose%20of%20a%20Sparse%20matrix%20%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A&amp;source=bugs of a debugger" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html&amp;title=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix" rel="nofollow" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix&amp;link=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html&amp;t=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix" rel="nofollow" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="sexy-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html&amp;title=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix" rel="nofollow" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="sexy-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html&amp;title=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix" rel="nofollow" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html&amp;n=C%2B%2B+Program+to+find+the+transpose+of+a+Sparse+matrix&amp;pli=1" rel="nofollow" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Farunmvishnu.com%2Fprogramming%2Fc-and-c%2Fc-program-find-the-transpose-of-a-sparse-matrix.html&amp;linkname=C%2B%2B%20Program%20to%20find%20the%20transpose%20of%20a%20Sparse%20matrix"><img src="http://arunmvishnu.com/home/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://arunmvishnu.com/programming/c-and-c/c-program-find-the-transpose-of-a-sparse-matrix.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C++ Program to implement a single linked list</title>
		<link>http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html</link>
		<comments>http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html#comments</comments>
		<pubDate>Thu, 27 Nov 2008 20:01:05 +0000</pubDate>
		<dc:creator>Arun Vishnu</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[c and cpp]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://arunmvishnu.com/?p=609</guid>
		<description><![CDATA[C++ Program to implement a single linked list and Perform the following operations.

/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program to implement a single linked list and Perform the following operations
		 1: Insertioin
		 2: Deletion
         3: Display
***************************************************************/
#include&#60;conio.h&#62;   	
#include&#60;iostream.h&#62; 
#include&#60;process.h&#62;  
&#160;
//   Creating a [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>C++ Program to implement a single linked list and Perform the following operations.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #ff0000; font-style: italic;">/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program to implement a single linked list and Perform the following operations
		 1: Insertioin
		 2: Deletion
         3: Display
***************************************************************/</span>
<span style="color: #339900;">#include&lt;conio.h&gt;   	</span>
<span style="color: #339900;">#include&lt;iostream.h&gt; </span>
<span style="color: #339900;">#include&lt;process.h&gt;  </span>
&nbsp;
<span style="color: #666666;">//   Creating a NODE Structure</span>
<span style="color: #0000ff;">struct</span> node
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> data<span style="color: #008080;">;</span>  <span style="color: #666666;">// data</span>
	<span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>next,<span style="color: #000040;">*</span>start<span style="color: #008080;">;</span> <span style="color: #666666;">//  link to next node and previous node</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #666666;">// Creating a class LIST</span>
<span style="color: #0000ff;">class</span> list
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>start<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
		<span style="color: #0000ff;">void</span> create<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// to create a list</span>
		<span style="color: #0000ff;">void</span> insert<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>  <span style="color: #666666;">// insertion</span>
		<span style="color: #0000ff;">void</span> del<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>    <span style="color: #666666;">// deletion</span>
		<span style="color: #0000ff;">void</span> show<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>   <span style="color: #666666;">// show</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
<span style="color: #666666;">// Creating a new node</span>
<span style="color: #0000ff;">void</span> list<span style="color: #008080;">::</span><span style="color: #007788;">create</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>nxt_node,<span style="color: #000040;">*</span>pre_node<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">int</span> value,no,i<span style="color: #008080;">;</span>
	start<span style="color: #000080;">=</span>nxt_node<span style="color: #000080;">=</span>pre_node<span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>CREATING A NEW LIST.........<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>How many nodes : &quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>no<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;=</span>no<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Enter &quot;</span><span style="color: #000080;">&lt;&lt;</span>no<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot; DATAs: &quot;</span><span style="color: #008080;">;</span>
		<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>value<span style="color: #008080;">;</span>
		nxt_node<span style="color: #000080;">=</span><span style="color: #0000dd;">new</span> node<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>pre_node<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span>
			pre_node<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">=</span>nxt_node<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>start<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span>
		  start<span style="color: #000080;">=</span>nxt_node<span style="color: #008080;">;</span>
		nxt_node<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #000080;">=</span>value<span style="color: #008080;">;</span>
		nxt_node<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
		pre_node<span style="color: #000080;">=</span>nxt_node<span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>The list is created!&quot;</span><span style="color: #008080;">;</span>
	show<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #666666;">// Displaying LIST</span>
<span style="color: #0000ff;">void</span> list<span style="color: #008080;">::</span><span style="color: #007788;">show</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> data<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>ptr<span style="color: #000080;">=</span>start<span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>The List is <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span>ptr<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		data<span style="color: #000080;">=</span>ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #008080;">;</span>
		<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>data<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot; -&gt; &quot;</span><span style="color: #008080;">;</span>
		ptr<span style="color: #000080;">=</span>ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\b</span><span style="color: #000099; font-weight: bold;">\b</span><span style="color: #000099; font-weight: bold;">\b</span>   &quot;</span><span style="color: #008080;">;</span>
	getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #666666;">// Insert node at any position</span>
<span style="color: #0000ff;">void</span> list<span style="color: #008080;">::</span><span style="color: #007788;">insert</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> position,dat<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>ptr_b,<span style="color: #000040;">*</span>ptr_f,<span style="color: #000040;">*</span>ptr,<span style="color: #000040;">*</span>nxt_node,<span style="color: #000040;">*</span>pre_node<span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Insertion of a new node <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Enter the DATA after which the new node is to be inserted.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;[ If the data is not found the new node will be&quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot; created at first ]<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span>-&gt;:  &quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>position<span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Enter the data to insert: &quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>dat<span style="color: #008080;">;</span>
	ptr_b<span style="color: #000080;">=</span>start<span style="color: #008080;">;</span>
	ptr<span style="color: #000080;">=</span><span style="color: #0000dd;">new</span> node<span style="color: #008080;">;</span>
	ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #000080;">=</span>dat<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>start<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span>ptr_b<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span> <span style="color: #000040;">&amp;&amp;</span> ptr_b<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #000040;">!</span><span style="color: #000080;">=</span>position<span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
			ptr_b<span style="color: #000080;">=</span>ptr_b<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">else</span>
	<span style="color: #008000;">&#123;</span>
		clrscr<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		start<span style="color: #000080;">=</span>nxt_node<span style="color: #000080;">=</span>pre_node<span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
		nxt_node<span style="color: #000080;">=</span><span style="color: #0000dd;">new</span> node<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>pre_node<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span>
			pre_node<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">=</span>nxt_node<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>start<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span>
		  start<span style="color: #000080;">=</span>nxt_node<span style="color: #008080;">;</span>
		nxt_node<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #000080;">=</span>dat<span style="color: #008080;">;</span>
		nxt_node<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
		pre_node<span style="color: #000080;">=</span>nxt_node<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">return</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>ptr_b<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span> <span style="color: #000040;">&amp;&amp;</span> ptr_b<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #000040;">!</span><span style="color: #000080;">=</span>position<span style="color: #008000;">&#41;</span>
	<span style="color: #666666;">//Insertion at first</span>
	<span style="color: #008000;">&#123;</span>
		ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">=</span>start<span style="color: #008080;">;</span>
		start<span style="color: #000080;">=</span>ptr<span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>ptr_b<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span> <span style="color: #000040;">&amp;&amp;</span> ptr_b<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #000080;">==</span>position<span style="color: #008000;">&#41;</span>
	<span style="color: #666666;">//insertion at the end of list</span>
	<span style="color: #008000;">&#123;</span>
		ptr_b<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">=</span>ptr<span style="color: #008080;">;</span>
		ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
 	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">else</span>
	<span style="color: #666666;">//Insertion between two nodes</span>
	<span style="color: #008000;">&#123;</span>
		ptr_f<span style="color: #000080;">=</span>ptr_b<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
		ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">=</span>ptr_b<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
		ptr_b<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">=</span>ptr<span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>New node is inserted!!&quot;</span><span style="color: #008080;">;</span>
	getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>  <span style="color: #666666;">//End of insertion</span>
&nbsp;
<span style="color: #666666;">//Delete node from any position</span>
<span style="color: #0000ff;">void</span> list<span style="color: #008080;">::</span><span style="color: #007788;">del</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> position,dat<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>ptr_b,<span style="color: #000040;">*</span>ptr_f,<span style="color: #000040;">*</span>ptr,<span style="color: #000040;">*</span>pntr<span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Enter the data to be beleted: &quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>position<span style="color: #008080;">;</span>
	ptr<span style="color: #000080;">=</span>start<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span>ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span> <span style="color: #000040;">&amp;&amp;</span> ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #000040;">!</span><span style="color: #000080;">=</span>position<span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		pntr<span style="color: #000080;">=</span>ptr<span style="color: #008080;">;</span>
		ptr<span style="color: #000080;">=</span>ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span> <span style="color: #000040;">&amp;&amp;</span> ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #000040;">!</span><span style="color: #000080;">=</span>position<span style="color: #008000;">&#41;</span>
	<span style="color: #666666;">//Data not found</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Data not found!!&quot;</span><span style="color: #008080;">;</span>
		getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">return</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span> <span style="color: #000040;">&amp;&amp;</span> ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #000080;">==</span>position<span style="color: #008000;">&#41;</span>
	<span style="color: #666666;">//Deletion from the end of list</span>
	<span style="color: #008000;">&#123;</span>
		ptr_b<span style="color: #000080;">=</span>pntr<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>pntr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008000;">&#41;</span><span style="color: #666666;">//  Only one node</span>
			start<span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
		dat<span style="color: #000080;">=</span>ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #008080;">;</span>
		ptr_b<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">else</span>
	<span style="color: #666666;">//Deletion between two nodes or first node</span>
	<span style="color: #008000;">&#123;</span>
		dat<span style="color: #000080;">=</span>ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>start<span style="color: #000080;">==</span>ptr<span style="color: #008000;">&#41;</span>  <span style="color: #666666;">// delete first node</span>
		<span style="color: #008000;">&#123;</span>
			start<span style="color: #000080;">=</span>ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
			ptr_f<span style="color: #000080;">=</span>start<span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
		<span style="color: #0000ff;">else</span> <span style="color: #666666;">// Deletion between two nodes</span>
		<span style="color: #008000;">&#123;</span>
			dat<span style="color: #000080;">=</span>ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #008080;">;</span>
			ptr_b<span style="color: #000080;">=</span>pntr<span style="color: #008080;">;</span>
			ptr_b<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">=</span>ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
			<span style="color: #666666;">//ptr_f=ptr_b-&gt;next;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000dd;">delete</span> ptr<span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>The node is deleted!!<span style="color: #000099; font-weight: bold;">\n</span>Data= &quot;</span><span style="color: #000080;">&lt;&lt;</span>dat<span style="color: #008080;">;</span>
	getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>  <span style="color: #666666;">//End of deletion</span>
&nbsp;
&nbsp;
<span style="color: #666666;">// Main function</span>
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	clrscr<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	list l<span style="color: #008080;">;</span>
	l.<span style="color: #007788;">create</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// to create a new node</span>
	<span style="color: #0000ff;">int</span> choice<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>-------------------------------------------&quot;</span><span style="color: #008080;">;</span>
		<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span> LINKED LIST<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
		<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;1:Insertion<span style="color: #000099; font-weight: bold;">\n</span>2:Deletion<span style="color: #000099; font-weight: bold;">\n</span>3:Display List<span style="color: #000099; font-weight: bold;">\n</span>4:Exit&quot;</span><span style="color: #008080;">;</span>
		<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Enter your choice(1-4): &quot;</span><span style="color: #008080;">;</span>
		<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>choice<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">switch</span><span style="color: #008000;">&#40;</span>choice<span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
		 <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">:</span>  <span style="color: #666666;">// Insertion</span>
			l.<span style="color: #007788;">insert</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			 <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
		 <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">2</span><span style="color: #008080;">:</span>   <span style="color: #666666;">// Deletion</span>
			l.<span style="color: #007788;">del</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>   
		 <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">3</span><span style="color: #008080;">:</span>  <span style="color: #666666;">// Display</span>
			l.<span style="color: #007788;">show</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
		 <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">4</span><span style="color: #008080;">:</span>  <span style="color: #666666;">// Exit</span>
			<span style="color: #0000dd;">exit</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
		 <span style="color: #0000ff;">default</span><span style="color: #008080;">:</span>
			<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Please enter correct choice(1-4)!!&quot;</span><span style="color: #008080;">;</span>
		 getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		 <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #666666;">//---------------------- END--------------------</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=C%2B%2B+Program+to+implement+a+single+linked+list&amp;du=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html&amp;cn=C%2B%2B%20Program%20to%20implement%20a%20single%20linked%20list%20and%20Perform%20the%20following%20operations.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20to%20implement%20a%20single%20linked%20list%20and%20Perform%20the%20following%20operatio" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html&amp;t=C%2B%2B+Program+to+implement+a+single+linked+list" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+single+linked+list" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+single+linked+list" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=C%2B%2B+Program+to+implement+a+single+linked+list+-+http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html+(via+@arunmvishnu)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+single+linked+list" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html&amp;submitHeadline=C%2B%2B+Program+to+implement+a+single+linked+list&amp;submitSummary=C%2B%2B%20Program%20to%20implement%20a%20single%20linked%20list%20and%20Perform%20the%20following%20operations.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20to%20implement%20a%20single%20linked%20list%20and%20Perform%20the%20following%20operatio&amp;submitCategory=science&amp;submitAssetType=image" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+single+linked+list" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-myspace">
			<a href="http://www.myspace.com/Modules/PostTo/Pages/?u=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html&amp;t=C%2B%2B+Program+to+implement+a+single+linked+list" rel="nofollow" title="Post this to MySpace">Post this to MySpace</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+single+linked+list&amp;summary=C%2B%2B%20Program%20to%20implement%20a%20single%20linked%20list%20and%20Perform%20the%20following%20operations.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20to%20implement%20a%20single%20linked%20list%20and%20Perform%20the%20following%20operatio&amp;source=bugs of a debugger" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+single+linked+list" rel="nofollow" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=C%2B%2B+Program+to+implement+a+single+linked+list&amp;link=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html&amp;t=C%2B%2B+Program+to+implement+a+single+linked+list" rel="nofollow" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="sexy-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+single+linked+list" rel="nofollow" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="sexy-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+single+linked+list" rel="nofollow" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html&amp;n=C%2B%2B+Program+to+implement+a+single+linked+list&amp;pli=1" rel="nofollow" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Farunmvishnu.com%2Fprogramming%2Fc-and-c%2Fc-program-to-implement-a-single-linked-list.html&amp;linkname=C%2B%2B%20Program%20to%20implement%20a%20single%20linked%20list"><img src="http://arunmvishnu.com/home/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-single-linked-list.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>C++ Program for Selection sort</title>
		<link>http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html</link>
		<comments>http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html#comments</comments>
		<pubDate>Thu, 27 Nov 2008 19:58:52 +0000</pubDate>
		<dc:creator>Arun Vishnu</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[c and cpp]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://arunmvishnu.com/?p=607</guid>
		<description><![CDATA[C++ Program for Selection sort .

/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program for Selection sort .
***************************************************************/
#include&#60;conio.h&#62;   	
#include&#60;iostream.h&#62; 
#include&#60;process.h&#62;  
&#160;
void main&#40;&#41;
&#123;
	int array&#91;100&#93;,n,i,j,temp;
	clrscr&#40;&#41;;
	cout&#60;&#60;&#34;How many numbers--&#62; &#34;;
	cin&#62;&#62;n;
	cout&#60;&#60;&#34;Enter &#34;&#60;&#60;n&#60;&#60;&#34; numbers\n&#34;;
	for&#40;i=0;i&#60;n;i++&#41;
		cin&#62;&#62;array&#91;i&#93;;
	for&#40;i=0;i&#60;n;i++&#41;
	&#123;
		for&#40;j=i+1;j&#60;n;j++&#41;
			if&#40;array&#91;i&#93;&#62;array&#91;j&#93;&#41;
			&#123;
				temp=array&#91;i&#93;;
				array&#91;i&#93;=array&#91;j&#93;;
				array&#91;j&#93;=temp;
			&#125;
	&#125;
	cout&#60;&#60;&#34;\nArray is sorted in ascending order.\n&#34;;
	for&#40;i=0;i&#60;n;i++&#41;
		cout&#60;&#60;array&#91;i&#93;&#60;&#60;&#34;   &#34;;
	getch&#40;&#41;;
&#125;
//---------------------- END--------------------






		
			Promote this on Orkut
		
		
			Share this on Facebook
		
		
			Digg this!
		
		
			Share this on del.icio.us
		
		
			Tweet This!
		
		
			Share this on Reddit
		
		
			Buzz up!
		
		
			Stumble upon [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>C++ Program for Selection sort .</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #ff0000; font-style: italic;">/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program for Selection sort .
***************************************************************/</span>
<span style="color: #339900;">#include&lt;conio.h&gt;   	</span>
<span style="color: #339900;">#include&lt;iostream.h&gt; </span>
<span style="color: #339900;">#include&lt;process.h&gt;  </span>
&nbsp;
<span style="color: #0000ff;">void</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> array<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">100</span><span style="color: #008000;">&#93;</span>,n,i,j,temp<span style="color: #008080;">;</span>
	clrscr<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;How many numbers--&gt; &quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>n<span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Enter &quot;</span><span style="color: #000080;">&lt;&lt;</span>n<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot; numbers<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;</span>n<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
		<span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>array<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;</span>n<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>j<span style="color: #000080;">=</span>i<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>j<span style="color: #000080;">&lt;</span>n<span style="color: #008080;">;</span>j<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
			<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>array<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #000080;">&gt;</span>array<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span>
			<span style="color: #008000;">&#123;</span>
				temp<span style="color: #000080;">=</span>array<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
				array<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>array<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
				array<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span>temp<span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Array is sorted in ascending order.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span><span style="color: #008000;">&#40;</span>i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>i<span style="color: #000080;">&lt;</span>n<span style="color: #008080;">;</span>i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
		<span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>array<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;   &quot;</span><span style="color: #008080;">;</span>
	getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #666666;">//---------------------- END--------------------</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=C%2B%2B+Program+for+Selection+sort+&amp;du=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html&amp;cn=C%2B%2B%20Program%20for%20Selection%20sort%20.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20for%20Selection%20sort%20.%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%23include%20%20%20%09%0D%0A%23include%20%0D%0A%23inclu" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html&amp;t=C%2B%2B+Program+for+Selection+sort+" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html&amp;title=C%2B%2B+Program+for+Selection+sort+" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html&amp;title=C%2B%2B+Program+for+Selection+sort+" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=C%2B%2B+Program+for+Selection+sort++-+http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html+(via+@arunmvishnu)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html&amp;title=C%2B%2B+Program+for+Selection+sort+" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html&amp;submitHeadline=C%2B%2B+Program+for+Selection+sort+&amp;submitSummary=C%2B%2B%20Program%20for%20Selection%20sort%20.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20for%20Selection%20sort%20.%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%23include%20%20%20%09%0D%0A%23include%20%0D%0A%23inclu&amp;submitCategory=science&amp;submitAssetType=image" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html&amp;title=C%2B%2B+Program+for+Selection+sort+" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-myspace">
			<a href="http://www.myspace.com/Modules/PostTo/Pages/?u=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html&amp;t=C%2B%2B+Program+for+Selection+sort+" rel="nofollow" title="Post this to MySpace">Post this to MySpace</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html&amp;title=C%2B%2B+Program+for+Selection+sort+&amp;summary=C%2B%2B%20Program%20for%20Selection%20sort%20.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20for%20Selection%20sort%20.%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%23include%20%20%20%09%0D%0A%23include%20%0D%0A%23inclu&amp;source=bugs of a debugger" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html&amp;title=C%2B%2B+Program+for+Selection+sort+" rel="nofollow" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=C%2B%2B+Program+for+Selection+sort+&amp;link=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html&amp;t=C%2B%2B+Program+for+Selection+sort+" rel="nofollow" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="sexy-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html&amp;title=C%2B%2B+Program+for+Selection+sort+" rel="nofollow" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="sexy-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html&amp;title=C%2B%2B+Program+for+Selection+sort+" rel="nofollow" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html&amp;n=C%2B%2B+Program+for+Selection+sort+&amp;pli=1" rel="nofollow" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Farunmvishnu.com%2Fprogramming%2Fc-and-c%2Fc-program-for-selection-sort.html&amp;linkname=C%2B%2B%20Program%20for%20Selection%20sort"><img src="http://arunmvishnu.com/home/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://arunmvishnu.com/programming/c-and-c/c-program-for-selection-sort.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C++ Program for QUICK SORT</title>
		<link>http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html</link>
		<comments>http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html#comments</comments>
		<pubDate>Thu, 27 Nov 2008 19:57:39 +0000</pubDate>
		<dc:creator>Arun Vishnu</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[c and cpp]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://arunmvishnu.com/?p=605</guid>
		<description><![CDATA[C++ Program for QUICK SORT.

/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program for QUICK SORT.
***************************************************************/
#include&#60;conio.h&#62;  	
#include&#60;iostream.h&#62; 
#include&#60;process.h&#62;  
&#160;
void quickSort&#40;int numbers&#91;&#93;, int array_size&#41;;
void q_sort&#40;int numbers&#91;&#93;, int left, int right&#41;;
&#160;
int numbers&#91;150&#93;;
&#160;
int main&#40;&#41;
&#123;
   clrscr&#40;&#41;;
   int i,n;
   cout&#60;&#60;&#34;How many numbers you want to sort: &#34;;
   cin&#62;&#62;n;
   cout&#60;&#60;&#34;Enter [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>C++ Program for QUICK SORT.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #ff0000; font-style: italic;">/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program for QUICK SORT.
***************************************************************/</span>
<span style="color: #339900;">#include&lt;conio.h&gt;  	</span>
<span style="color: #339900;">#include&lt;iostream.h&gt; </span>
<span style="color: #339900;">#include&lt;process.h&gt;  </span>
&nbsp;
<span style="color: #0000ff;">void</span> quickSort<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> numbers<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span>, <span style="color: #0000ff;">int</span> array_size<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #0000ff;">void</span> q_sort<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> numbers<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span>, <span style="color: #0000ff;">int</span> left, <span style="color: #0000ff;">int</span> right<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">int</span> numbers<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">150</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   clrscr<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">int</span> i,n<span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;How many numbers you want to sort: &quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>n<span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Enter &quot;</span><span style="color: #000080;">&lt;&lt;</span>n<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot; numbers.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span>i <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i<span style="color: #000080;">&lt;</span>n<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
      <span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>numbers<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
<span style="color: #666666;">//perform quick sort on array</span>
   q_sort<span style="color: #008000;">&#40;</span>numbers,<span style="color: #0000dd;">0</span>,n<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Numbers are sorted<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span>i <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i<span style="color: #000080;">&lt;</span>n<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>numbers<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;   &quot;</span><span style="color: #008080;">;</span>
   getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">return</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #666666;">// Function to sort</span>
<span style="color: #0000ff;">void</span> q_sort<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> numbers<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span>, <span style="color: #0000ff;">int</span> left, <span style="color: #0000ff;">int</span> right<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   <span style="color: #0000ff;">int</span> pivot, l_hold, r_hold<span style="color: #008080;">;</span>
   l_hold <span style="color: #000080;">=</span> left<span style="color: #008080;">;</span>
   r_hold <span style="color: #000080;">=</span> right<span style="color: #008080;">;</span>
   pivot <span style="color: #000080;">=</span> numbers<span style="color: #008000;">&#91;</span>left<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>left <span style="color: #000080;">&lt;</span> right<span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>numbers<span style="color: #008000;">&#91;</span>right<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&gt;=</span> pivot<span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;&amp;</span> <span style="color: #008000;">&#40;</span>left <span style="color: #000080;">&lt;</span> right<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
      right<span style="color: #000040;">--</span><span style="color: #008080;">;</span>
      <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>left <span style="color: #000040;">!</span><span style="color: #000080;">=</span> right<span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
	 numbers<span style="color: #008000;">&#91;</span>left<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> numbers<span style="color: #008000;">&#91;</span>right<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	 left<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
      <span style="color: #008000;">&#125;</span>
      <span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>numbers<span style="color: #008000;">&#91;</span>left<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&lt;=</span> pivot<span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;&amp;</span> <span style="color: #008000;">&#40;</span>left <span style="color: #000080;">&lt;</span> right<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
	 left<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
      <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>left <span style="color: #000040;">!</span><span style="color: #000080;">=</span> right<span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
	  numbers<span style="color: #008000;">&#91;</span>right<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> numbers<span style="color: #008000;">&#91;</span>left<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	  right<span style="color: #000040;">--</span><span style="color: #008080;">;</span>
      <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
   numbers<span style="color: #008000;">&#91;</span>left<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> pivot<span style="color: #008080;">;</span>
   pivot <span style="color: #000080;">=</span> left<span style="color: #008080;">;</span>
   left <span style="color: #000080;">=</span> l_hold<span style="color: #008080;">;</span>
   right <span style="color: #000080;">=</span> r_hold<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>left <span style="color: #000080;">&lt;</span> pivot<span style="color: #008000;">&#41;</span>
      q_sort<span style="color: #008000;">&#40;</span>numbers, left, pivot<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>right <span style="color: #000080;">&gt;</span> pivot<span style="color: #008000;">&#41;</span>
      q_sort<span style="color: #008000;">&#40;</span>numbers, pivot<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span>, right<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666;">//---------------------- END--------------------</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=C%2B%2B+Program+for+QUICK+SORT&amp;du=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html&amp;cn=C%2B%2B%20Program%20for%20QUICK%20SORT.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20for%20QUICK%20SORT.%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%23include%20%20%09%0D%0A%23include%20%0D%0A%23include%20%20%0D%0A%0D%0Avoi" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html&amp;t=C%2B%2B+Program+for+QUICK+SORT" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html&amp;title=C%2B%2B+Program+for+QUICK+SORT" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html&amp;title=C%2B%2B+Program+for+QUICK+SORT" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=C%2B%2B+Program+for+QUICK+SORT+-+http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html+(via+@arunmvishnu)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html&amp;title=C%2B%2B+Program+for+QUICK+SORT" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html&amp;submitHeadline=C%2B%2B+Program+for+QUICK+SORT&amp;submitSummary=C%2B%2B%20Program%20for%20QUICK%20SORT.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20for%20QUICK%20SORT.%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%23include%20%20%09%0D%0A%23include%20%0D%0A%23include%20%20%0D%0A%0D%0Avoi&amp;submitCategory=science&amp;submitAssetType=image" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html&amp;title=C%2B%2B+Program+for+QUICK+SORT" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-myspace">
			<a href="http://www.myspace.com/Modules/PostTo/Pages/?u=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html&amp;t=C%2B%2B+Program+for+QUICK+SORT" rel="nofollow" title="Post this to MySpace">Post this to MySpace</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html&amp;title=C%2B%2B+Program+for+QUICK+SORT&amp;summary=C%2B%2B%20Program%20for%20QUICK%20SORT.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20for%20QUICK%20SORT.%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2F%0D%0A%23include%20%20%09%0D%0A%23include%20%0D%0A%23include%20%20%0D%0A%0D%0Avoi&amp;source=bugs of a debugger" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html&amp;title=C%2B%2B+Program+for+QUICK+SORT" rel="nofollow" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=C%2B%2B+Program+for+QUICK+SORT&amp;link=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html&amp;t=C%2B%2B+Program+for+QUICK+SORT" rel="nofollow" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="sexy-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html&amp;title=C%2B%2B+Program+for+QUICK+SORT" rel="nofollow" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="sexy-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html&amp;title=C%2B%2B+Program+for+QUICK+SORT" rel="nofollow" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html&amp;n=C%2B%2B+Program+for+QUICK+SORT&amp;pli=1" rel="nofollow" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Farunmvishnu.com%2Fprogramming%2Fc-and-c%2Fc-program-for-quick-sort.html&amp;linkname=C%2B%2B%20Program%20for%20QUICK%20SORT"><img src="http://arunmvishnu.com/home/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://arunmvishnu.com/programming/c-and-c/c-program-for-quick-sort.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>C++ Program to implement a QUEUE using linked list</title>
		<link>http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html</link>
		<comments>http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html#comments</comments>
		<pubDate>Thu, 27 Nov 2008 19:54:51 +0000</pubDate>
		<dc:creator>Arun Vishnu</dc:creator>
				<category><![CDATA[C and C++]]></category>
		<category><![CDATA[c and cpp]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://arunmvishnu.com/?p=603</guid>
		<description><![CDATA[C++ Program to implement a QUEUE using linked list.

/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program to implement a QUEUE using linked list.
***************************************************************/
#include&#60;conio.h&#62;   	
#include&#60;iostream.h&#62; 
#include&#60;process.h&#62;  
#include&#60;malloc.h&#62;  
&#160;
//   Creating a NODE Structure
struct node
&#123;
   int data;
   struct node *next;
&#125;;
&#160;
// Creating a class QUEUE
class queue
&#123;
   struct [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>C++ Program to implement a QUEUE using linked list.</p>

<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #ff0000; font-style: italic;">/**************************************************************	
	Author: Arun Vishnu M V
	Web: www.arunmvishnu.com
	Description: C++ Program to implement a QUEUE using linked list.
***************************************************************/</span>
<span style="color: #339900;">#include&lt;conio.h&gt;   	</span>
<span style="color: #339900;">#include&lt;iostream.h&gt; </span>
<span style="color: #339900;">#include&lt;process.h&gt;  </span>
<span style="color: #339900;">#include&lt;malloc.h&gt;  </span>
&nbsp;
<span style="color: #666666;">//   Creating a NODE Structure</span>
<span style="color: #0000ff;">struct</span> node
<span style="color: #008000;">&#123;</span>
   <span style="color: #0000ff;">int</span> data<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>next<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #666666;">// Creating a class QUEUE</span>
<span style="color: #0000ff;">class</span> queue
<span style="color: #008000;">&#123;</span>
   <span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>frnt,<span style="color: #000040;">*</span>rear<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
      queue<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #666666;">// constructure</span>
      <span style="color: #008000;">&#123;</span>
	 frnt<span style="color: #000080;">=</span>rear<span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
      <span style="color: #008000;">&#125;</span>
      <span style="color: #0000ff;">void</span> insert<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// to insert an element</span>
      <span style="color: #0000ff;">void</span> del<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>  <span style="color: #666666;">// to delete an element</span>
      <span style="color: #0000ff;">void</span> show<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// to show the stack</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
<span style="color: #666666;">// Insertion</span>
<span style="color: #0000ff;">void</span> queue<span style="color: #008080;">::</span><span style="color: #007788;">insert</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   <span style="color: #0000ff;">int</span> value<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>ptr<span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Insertion<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Enter a number to insert: &quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>value<span style="color: #008080;">;</span>
   ptr<span style="color: #000080;">=</span><span style="color: #0000dd;">new</span> node<span style="color: #008080;">;</span>
   ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #000080;">=</span>value<span style="color: #008080;">;</span>
   ptr<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>frnt<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span>
      frnt<span style="color: #000080;">=</span>ptr<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">else</span>
      rear<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">=</span>ptr<span style="color: #008080;">;</span>
   rear<span style="color: #000080;">=</span>ptr<span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>New item is inserted to the Queue!!!&quot;</span><span style="color: #008080;">;</span>
   getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #666666;">// Deletion</span>
<span style="color: #0000ff;">void</span> queue<span style="color: #008080;">::</span><span style="color: #007788;">del</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>frnt<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Queue is empty!!&quot;</span><span style="color: #008080;">;</span>
      getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
      <span style="color: #0000ff;">return</span><span style="color: #008080;">;</span>
   <span style="color: #008000;">&#125;</span>
   <span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>temp<span style="color: #008080;">;</span>
   temp<span style="color: #000080;">=</span>frnt<span style="color: #008080;">;</span>
   frnt<span style="color: #000080;">=</span>frnt<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Deletion Operation........<span style="color: #000099; font-weight: bold;">\n</span>Deleted value is &quot;</span><span style="color: #000080;">&lt;&lt;</span>temp<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #008080;">;</span>
   <span style="color: #0000dd;">delete</span> temp<span style="color: #008080;">;</span>
   getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #666666;">// Show Queue</span>
<span style="color: #0000ff;">void</span> queue<span style="color: #008080;">::</span><span style="color: #007788;">show</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   <span style="color: #0000ff;">struct</span> node <span style="color: #000040;">*</span>ptr1<span style="color: #000080;">=</span>frnt<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>frnt<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;The Queue is empty!!&quot;</span><span style="color: #008080;">;</span>
      getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
      <span style="color: #0000ff;">return</span><span style="color: #008080;">;</span>
   <span style="color: #008000;">&#125;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>The Queue is<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
   <span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span>ptr1<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span>ptr1<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>data<span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot; -&gt;&quot;</span><span style="color: #008080;">;</span>
      ptr1<span style="color: #000080;">=</span>ptr1<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
   <span style="color: #008000;">&#125;</span>
   <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;END&quot;</span><span style="color: #008080;">;</span>
   getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #666666;">// Main function</span>
<span style="color: #0000ff;">int</span> main<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   clrscr<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
   queue q<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">int</span> choice<span style="color: #008080;">;</span>
   <span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>-----------------------------------------------------------&quot;</span><span style="color: #008080;">;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>QUEUE USING LINKED LIST<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008080;">;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;1:INSERTION<span style="color: #000099; font-weight: bold;">\n</span>2:DELETION<span style="color: #000099; font-weight: bold;">\n</span>3:DISPLAY QUEUE<span style="color: #000099; font-weight: bold;">\n</span>4:EXIT&quot;</span><span style="color: #008080;">;</span>
      <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Enter your choice(1-4): &quot;</span><span style="color: #008080;">;</span>
      <span style="color: #0000dd;">cin</span><span style="color: #000080;">&gt;&gt;</span>choice<span style="color: #008080;">;</span>
      <span style="color: #0000ff;">switch</span><span style="color: #008000;">&#40;</span>choice<span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
       <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">:</span>
	  q.<span style="color: #007788;">insert</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	  <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
       <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">2</span><span style="color: #008080;">:</span>
	  q.<span style="color: #007788;">del</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	  <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
       <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">3</span><span style="color: #008080;">:</span>
	  q.<span style="color: #007788;">show</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	  <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
       <span style="color: #0000ff;">case</span> <span style="color: #0000dd;">4</span><span style="color: #008080;">:</span>
	  <span style="color: #0000dd;">exit</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	  <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
       <span style="color: #0000ff;">default</span><span style="color: #008080;">:</span>
	  <span style="color: #0000dd;">cout</span><span style="color: #000080;">&lt;&lt;</span><span style="color: #FF0000;">&quot;Please enter correct choice(1-4)!!&quot;</span><span style="color: #008080;">;</span>
	  getch<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	  <span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
       <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
   <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #666666;">//---------------------- END--------------------</span></pre></div></div>



<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand">
<ul class="socials">
		<li class="sexy-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list&amp;du=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html&amp;cn=C%2B%2B%20Program%20to%20implement%20a%20QUEUE%20using%20linked%20list.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20to%20implement%20a%20QUEUE%20using%20linked%20list.%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html&amp;t=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list+-+http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html+(via+@arunmvishnu)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-reddit">
			<a href="http://reddit.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list" rel="nofollow" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="sexy-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html&amp;submitHeadline=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list&amp;submitSummary=C%2B%2B%20Program%20to%20implement%20a%20QUEUE%20using%20linked%20list.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20to%20implement%20a%20QUEUE%20using%20linked%20list.%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A&amp;submitCategory=science&amp;submitAssetType=image" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-myspace">
			<a href="http://www.myspace.com/Modules/PostTo/Pages/?u=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html&amp;t=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list" rel="nofollow" title="Post this to MySpace">Post this to MySpace</a>
		</li>
		<li class="sexy-comfeed">
			<a href="http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list&amp;summary=C%2B%2B%20Program%20to%20implement%20a%20QUEUE%20using%20linked%20list.%0D%0A%0D%0A%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%09%0D%0A%09Author%3A%20Arun%20Vishnu%20M%20V%0D%0A%09Web%3A%20www.arunmvishnu.com%0D%0A%09Description%3A%20C%2B%2B%20Program%20to%20implement%20a%20QUEUE%20using%20linked%20list.%0D%0A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A&amp;source=bugs of a debugger" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-google">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list" rel="nofollow" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="sexy-friendfeed">
			<a href="http://www.friendfeed.com/share?title=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list&amp;link=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="sexy-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html&amp;t=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list" rel="nofollow" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="sexy-wikio">
			<a href="http://www.wikio.com/sharethis?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list" rel="nofollow" title="Share this on Wikio">Share this on Wikio</a>
		</li>
		<li class="sexy-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html&amp;title=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list" rel="nofollow" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="sexy-blogger">
			<a href="http://www.blogger.com/blog_this.pyra?t&amp;u=http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html&amp;n=C%2B%2B+Program+to+implement+a+QUEUE+using+linked+list&amp;pli=1" rel="nofollow" title="Blog this on Blogger">Blog this on Blogger</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Farunmvishnu.com%2Fprogramming%2Fc-and-c%2Fc-program-to-implement-a-queue-using-linked-list.html&amp;linkname=C%2B%2B%20Program%20to%20implement%20a%20QUEUE%20using%20linked%20list"><img src="http://arunmvishnu.com/home/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://arunmvishnu.com/programming/c-and-c/c-program-to-implement-a-queue-using-linked-list.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- This site's performance optimized by W3 Total Cache. Dramatically improve the speed and reliability of your blog!

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)
Database Caching using disk

Served from: server1.shellboy.com @ 2010-09-10 01:27:06 -->