<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9050761206169980588</id><updated>2024-12-19T08:52:13.217+05:30</updated><category term="Data Structure"/><category term="C Programs"/><category term="Arrays"/><category term="Array"/><category term="Java Programs"/><category term="Iterative Statements"/><category term="Decision Making Statements"/><category term="Linked List(Self Referential structure)"/><category term="Functions"/><category term="Array in Java"/><category term="C Tutorial"/><category term="Recursion"/><category term="Sorting"/><category term="Operators"/><category term="Stack"/><category term="String"/><category term="LPP"/><category term="Looping Statements"/><category term="Queue"/><category term="Searching"/><category term="Structure"/><category term="CPP Program"/><category term="Union"/><title type='text'>Era Of Skills</title><subtitle type='html'>Where Your Need Ends</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>152</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-3016779707695598573</id><published>2011-10-02T11:09:00.000+05:30</published><updated>2011-10-12T20:41:04.544+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="LPP"/><title type='text'>Vogel approximation method (VAM) in transportation problem</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;cview&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigAuOzLsfh4ILB-pXoaExqgXf_bDL_Bqam4m3ADkxIGX7Sl0xMzQm_aini5SOoTQ2V61Zb6tlnJ0yPDfbOBWJDuM9YLaZrg2TNTNYM-jUocfO-Bg0q7m3GsBLVp_IZL6mlU77gR7d1H0Yv/s320/NorthwestCorrner.png&quot; width=&quot;0&quot; /&gt;
//Vogel approximation method (VAM) in transportation problem&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
int res,des,*s,*d,**cell,**cost,i,j,r1,c1,r2,c2,p,q,a1,a2,max1,max2,min1,min2,sumreq=0,count=0,sumdes=0,total=0,*rowpanl,*colpanl;&lt;br /&gt;
printf(&quot;Enter number of resources: &quot;);&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;res);&lt;br /&gt;
printf(&quot;Enter the number of destinations: &quot;);&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;des);&lt;br /&gt;
&lt;br /&gt;
//memory allocation&lt;br /&gt;
s=(int *)malloc(res*sizeof(int));&lt;br /&gt;
rowpanl=(int *)malloc(res*sizeof(int));&lt;br /&gt;
d=(int *)malloc(des*sizeof(int));&lt;br /&gt;
colpanl=(int *)malloc(des*sizeof(int));&lt;br /&gt;
cell=(int **)malloc(res*sizeof(int *));&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
cell[i]=(int *)malloc(des*sizeof(int));&lt;br /&gt;
cost=(int **)malloc(res*sizeof(int *));&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
cost[i]=(int *)malloc(des*sizeof(int));&lt;br /&gt;
&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
for(j=0;j&amp;lt;des;j++)&lt;br /&gt;
cell[i][j]=-1;&lt;br /&gt;
//memory allocated&lt;br /&gt;
&lt;br /&gt;
//data entering&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot;Enter the %dth resource availability: &quot;,i+1);&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;s[i]);&lt;br /&gt;
sumreq+=s[i];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
for(i=0;i&amp;lt;des;i++)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot;Enter the %dth destination requirement: &quot;,i+1);&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;d[i]);&lt;br /&gt;
sumdes+=d[i];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
for(j=0;j&amp;lt;des;j++)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot;Enter the cost %d %d :&quot;,i,j );&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;cost[i][j]);&lt;br /&gt;
}&lt;br /&gt;
//data entry complete&lt;br /&gt;
&lt;br /&gt;
//vam method starts&lt;br /&gt;
if(sumreq==sumdes)&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; while(count&amp;lt;res+des-1&amp;amp;&amp;amp;sumdes!=0)&lt;br /&gt;
&amp;nbsp; { &amp;nbsp; &lt;br /&gt;
&amp;nbsp; //Finding row panalties &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(s[i]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;rowpanl[i]=-2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min1=min2=10000;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(j=0;j&amp;lt;des;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(d[j]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(min1&amp;gt;=cost[i][j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min1=cost[i][j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p=j; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;des;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(d[j]==0||p==j)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(min2&amp;gt;=cost[i][j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min2=cost[i][j]; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(min2!=10000)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rowpanl[i]=min2-min1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rowpanl[i]=min1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;//row panalties founded\&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; //Finding column panalties &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;des;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(d[j]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;colpanl[j]=-2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min1=min2=10000;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(s[i]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(min1&amp;gt;=cost[i][j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min1=cost[i][j]; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p=i; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(s[i]==0||p==i)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(min2&amp;gt;=cost[i][j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min2=cost[i][j]; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(min2!=10000)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; colpanl[j]=min2-min1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; colpanl[j]=min1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;//column panalties founded&lt;br /&gt;
&amp;nbsp; &amp;nbsp;//maximum Row Panality&lt;br /&gt;
&amp;nbsp; &amp;nbsp;max1=p=-1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(max1&amp;lt;rowpanl[i])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;max1=rowpanl[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p=i;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(max1==rowpanl[i])//if tie in maximum panalty &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min1=min2=10000;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(j=0;j&amp;lt;des;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(d[j]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(min1&amp;gt;cost[i][j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;min1=cost[i][j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;r1=i;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;c1=j;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(min2&amp;gt;cost[p][j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min2=cost[p][j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; r2=p;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c2=j; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Comparing &amp;nbsp;minimum cost &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(min2&amp;gt;min1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; max1=rowpanl[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p=i; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(min1==min2)// Tie in minimum costs&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a1=s[r1]&amp;lt;d[c1]?s[r1]:d[c1];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a2=s[r2]&amp;lt;d[c2]?s[r2]:d[c2];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(a2&amp;lt;a1) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// choosing maximum allocation&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;max1=rowpanl[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p=i; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else if(a2==a1)//tie in allocation&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(r1+c1&amp;lt;r2+c2) &amp;nbsp;//breaking tie&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;max1=rowpanl[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p=i; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;//max row panality founded&lt;br /&gt;
&amp;nbsp;//maximum Column Panality&lt;br /&gt;
&amp;nbsp; &amp;nbsp;max2=q=-1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(i=0;i&amp;lt;des;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(max2&amp;lt;colpanl[i])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;max2=colpanl[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;q=i;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(max2==colpanl[i])//if tie in maximum panalty &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min1=min2=10000;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(j=0;j&amp;lt;res;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(s[j]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(min1&amp;gt;cost[j][i])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;min1=cost[j][i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;r1=j;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;c1=i;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(min2&amp;gt;cost[j][q])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min2=cost[j][q];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; r2=j;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c2=q; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Comparing &amp;nbsp;minimum cost &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(min2&amp;gt;min1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; max2=colpanl[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; q=i; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(min1==min2)// Tie in minimum costs&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a1=s[r1]&amp;lt;d[c1]?s[r1]:d[c1];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a2=s[r2]&amp;lt;d[c2]?s[r2]:d[c2];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(a2&amp;lt;a1) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// choosing maximum allocation&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;max2=colpanl[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;q=i; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else if(a2==a1)//tie in allocation&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(r1+c1&amp;lt;r2+c2) &amp;nbsp;//breaking tie&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; max2=colpanl[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;q=i; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;//max column panality founded&lt;br /&gt;
&amp;nbsp; &amp;nbsp;//comparing row and column panalties to find maximum panalty&lt;br /&gt;
&amp;nbsp;if(max1&amp;gt;max2)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; min1=10000;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; q=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(j=0;j&amp;lt;des;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(d[j]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(min1&amp;gt;cost[p][j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;min1=cost[p][j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;q=j;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; else if(max1==max2)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;min1=min2=10000;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;r1=p;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;c2=q;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for(i=0;i&amp;lt;des;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(d[i]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(min1&amp;gt;cost[p][j]) &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min1=cost[p][j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c1=j;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;res;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(s[j]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(min2&amp;gt;cost[j][q])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;min2=cost[j][q];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;r2=j;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(min1&amp;lt;min2)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p=r1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;q=c1; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else if(min2&amp;lt;min1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p=r2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; q=c2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else //tie condition&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a1=s[r1]&amp;lt;d[c1]?s[r1]:d[c1];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a2=s[r2]&amp;lt;d[c2]?s[r2]:d[c2];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(a1&amp;gt;a2) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// choosing maximum allocation&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p=r1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;q=c1; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(a2&amp;gt;a1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p=r2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;q=c2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(a2==a1)//tie in allocation&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(r1+c1&amp;lt;r2+c2) &amp;nbsp;//breaking tie&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p=r1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;q=c1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p=r2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; q=c2; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;else &amp;nbsp;// when max1&amp;lt;max2&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; min1=10000;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; p=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(j=0;j&amp;lt;res;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(s[j]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(min1&amp;gt;cost[j][q])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;min1=cost[j][q];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p=j;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; } &lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;// comparing Complete&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(s[p]&amp;lt;d[q])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;cell[p][q]=s[p];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;d[q]=d[q]-s[p];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;sumdes=sumdes-s[p];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;s[p]=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else &lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; cell[p][q]=d[q];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; s[p]=s[p]-d[q];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; sumdes=sumdes-d[q];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; d[q]=0; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; } &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; count++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
//method completed&lt;br /&gt;
//output&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
for(j=0;j&amp;lt;des;j++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; if(cell[i][j]!=-1)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; printf(&quot;x[%d][%d]=%d &quot;,i,j,cell[i][j]);&lt;br /&gt;
&amp;nbsp; total+=cell[i][j]*cost[i][j];&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
printf(&quot;\nTotal transportation cost is %d&quot;,total);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
printf(&quot;Not a balanced problem&quot;);&lt;br /&gt;
getch();&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/3016779707695598573/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/10/vogel-approximation-method-vam-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/3016779707695598573'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/3016779707695598573'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/10/vogel-approximation-method-vam-in.html' title='Vogel approximation method (VAM) in transportation problem'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigAuOzLsfh4ILB-pXoaExqgXf_bDL_Bqam4m3ADkxIGX7Sl0xMzQm_aini5SOoTQ2V61Zb6tlnJ0yPDfbOBWJDuM9YLaZrg2TNTNYM-jUocfO-Bg0q7m3GsBLVp_IZL6mlU77gR7d1H0Yv/s72-c/NorthwestCorrner.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-5174630967285681106</id><published>2011-09-30T22:47:00.000+05:30</published><updated>2011-10-01T16:28:56.498+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="LPP"/><title type='text'>North West Corner Method in transportation problem</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;cview&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigAuOzLsfh4ILB-pXoaExqgXf_bDL_Bqam4m3ADkxIGX7Sl0xMzQm_aini5SOoTQ2V61Zb6tlnJ0yPDfbOBWJDuM9YLaZrg2TNTNYM-jUocfO-Bg0q7m3GsBLVp_IZL6mlU77gR7d1H0Yv/s320/NorthwestCorrner.png&quot; width=&quot;0&quot; /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//North West Corner Method in transportation problem&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
int res,des,*s,*d,**cell,**cost,i,j,sumreq=0,sumdes=0,c=0,total=0;&lt;br /&gt;
printf(&quot;Enter number of resources: &quot;);&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;res);&lt;br /&gt;
printf(&quot;Enter the number of destinations: &quot;);&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;des);&lt;br /&gt;
&lt;br /&gt;
//memory allocation&lt;br /&gt;
s=(int *)malloc(res*sizeof(int));&lt;br /&gt;
d=(int *)malloc(des*sizeof(int));&lt;br /&gt;
cell=(int **)malloc(res*sizeof(int *));&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
cell[i]=(int *)malloc(des*sizeof(int));&lt;br /&gt;
cost=(int **)malloc(res*sizeof(int *));&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
cost[i]=(int *)malloc(des*sizeof(int));&lt;br /&gt;
&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
for(j=0;j&amp;lt;des;j++)&lt;br /&gt;
cell[i][j]=-1;&lt;br /&gt;
//memory allocated&lt;br /&gt;
&lt;br /&gt;
//data entering&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot;Enter the %dth resource availability: &quot;,i+1);&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;s[i]);&lt;br /&gt;
sumreq+=s[i];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
for(i=0;i&amp;lt;des;i++)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot;Enter the %dth destination requirement: &quot;,i+1);&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;d[i]);&lt;br /&gt;
sumdes+=d[i];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
for(j=0;j&amp;lt;des;j++)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot;Enter the cost %d %d :&quot;,i,j );&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;cost[i][j]);&lt;br /&gt;
}&lt;br /&gt;
//data entry complete&lt;br /&gt;
&lt;br /&gt;
//nwc method starts&lt;br /&gt;
if(sumreq==sumdes)&lt;br /&gt;
{&lt;br /&gt;
i=0;&lt;br /&gt;
j=0;&lt;br /&gt;
while(i&amp;lt;res&amp;amp;&amp;amp;j&amp;lt;des)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;if(s[i]&amp;lt;d[j])&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;cell[i][j]=s[i];&lt;br /&gt;
&amp;nbsp;d[j]=d[j]-s[i];&lt;br /&gt;
&amp;nbsp;s[i]=s[i]-s[i];&lt;br /&gt;
&amp;nbsp;i++;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;else&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;cell[i][j]=d[j];&lt;br /&gt;
&amp;nbsp;s[i]=s[i]-d[j];&lt;br /&gt;
&amp;nbsp;d[j]=d[j]-d[j];&lt;br /&gt;
&amp;nbsp;j++;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
for(j=0;j&amp;lt;des;j++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; if(cell[i][j]!=-1)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; printf(&quot;x[%d][%d]=%d &quot;,i,j,cell[i][j]);&lt;br /&gt;
&amp;nbsp; total+=cell[i][j]*cost[i][j];&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
printf(&quot;\nTotal transportation cost is %d&quot;,total);&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
printf(&quot;Not a balanced problem&quot;);&lt;br /&gt;
getch();&lt;br /&gt;
}&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/5174630967285681106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/09/north-west-corner-methhod-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/5174630967285681106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/5174630967285681106'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/09/north-west-corner-methhod-in.html' title='North West Corner Method in transportation problem'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigAuOzLsfh4ILB-pXoaExqgXf_bDL_Bqam4m3ADkxIGX7Sl0xMzQm_aini5SOoTQ2V61Zb6tlnJ0yPDfbOBWJDuM9YLaZrg2TNTNYM-jUocfO-Bg0q7m3GsBLVp_IZL6mlU77gR7d1H0Yv/s72-c/NorthwestCorrner.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-920612721917191234</id><published>2011-09-30T22:33:00.001+05:30</published><updated>2011-10-12T20:41:58.366+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="LPP"/><title type='text'>Least Cost Entry Method in Transportation Problem</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;cview&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigAuOzLsfh4ILB-pXoaExqgXf_bDL_Bqam4m3ADkxIGX7Sl0xMzQm_aini5SOoTQ2V61Zb6tlnJ0yPDfbOBWJDuM9YLaZrg2TNTNYM-jUocfO-Bg0q7m3GsBLVp_IZL6mlU77gR7d1H0Yv/s320/NorthwestCorrner.png&quot; width=&quot;0&quot; /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;//Least Cost Entry Method in Transportation Problem&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
int res,des,*s,*d,**cell,**cost,i,j,p,q,t1,t2,min,sumreq=0,sumdes=0,count=0,total=0;&lt;br /&gt;
printf(&quot;Enter number of resources: &quot;);&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;res);&lt;br /&gt;
printf(&quot;Enter the number of destinations: &quot;);&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;des);&lt;br /&gt;
&lt;br /&gt;
//memory allocation&lt;br /&gt;
s=(int *)malloc(res*sizeof(int));&lt;br /&gt;
d=(int *)malloc(des*sizeof(int));&lt;br /&gt;
cell=(int **)malloc(res*sizeof(int *));&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
cell[i]=(int *)malloc(des*sizeof(int));&lt;br /&gt;
cost=(int **)malloc(res*sizeof(int *));&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
cost[i]=(int *)malloc(des*sizeof(int));&lt;br /&gt;
&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
for(j=0;j&amp;lt;des;j++)&lt;br /&gt;
cell[i][j]=-1;&lt;br /&gt;
//memory allocated&lt;br /&gt;
&lt;br /&gt;
//data entering&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot;Enter the %dth resource availability: &quot;,i+1);&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;s[i]);&lt;br /&gt;
sumreq+=s[i];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
for(i=0;i&amp;lt;des;i++)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot;Enter the %dth destination requirement: &quot;,i+1);&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;d[i]);&lt;br /&gt;
sumdes+=d[i];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
for(j=0;j&amp;lt;des;j++)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot;Enter the cost %d %d :&quot;,i,j );&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;cost[i][j]);&lt;br /&gt;
}&lt;br /&gt;
//data entry complete&lt;br /&gt;
&lt;br /&gt;
//lcem method starts&lt;br /&gt;
if(sumreq==sumdes)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; i=j=0;&lt;br /&gt;
&amp;nbsp; while(count&amp;lt;res+des-1)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; min=10000; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; for(p=0;p&amp;lt;res;p++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(s[p]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(q=0;q&amp;lt;des;q++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(d[q]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(min&amp;gt;cost[p][q])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;min=cost[p][q];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;i=p;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;j=q; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else if(min==cost[p][q]) //handling Same cost&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; t1=s[i]&amp;lt;d[j]?s[i]:d[j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; t2=s[p]&amp;lt;d[q]?s[p]:d[q];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(t2&amp;gt;t1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min=cost[p][q];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i=p;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j=q; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; } &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;if(s[i]&amp;lt;d[j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(s[i]!=-1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; cell[i][j]=s[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; d[j]=d[j]-s[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; s[i]=s[i]-s[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else //Degenrate Basic Variable&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; cell[i][j]=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; s[i]=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;else if(s[i]==d[j]) //Degenracy Problem Exit&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;cell[i][j]=s[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;d[j]=d[j]-s[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;s[i]=-1; &amp;nbsp; //Handling Degenrate Problem&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;else&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; cell[i][j]=d[j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; s[i]=s[i]-d[j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; d[j]=d[j]-d[j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; count++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
//method completed&lt;br /&gt;
&lt;br /&gt;
//output&lt;br /&gt;
for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
for(j=0;j&amp;lt;des;j++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; if(cell[i][j]!=-1)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; printf(&quot;x[%d][%d]=%d &quot;,i,j,cell[i][j]);&lt;br /&gt;
&amp;nbsp; total+=cell[i][j]*cost[i][j];&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
printf(&quot;\nTotal transportation cost is %d&quot;,total);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
printf(&quot;Not a balanced problem&quot;);&lt;br /&gt;
getch();&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/920612721917191234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/09/least-cost-entry-method-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/920612721917191234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/920612721917191234'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/09/least-cost-entry-method-in.html' title='Least Cost Entry Method in Transportation Problem'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigAuOzLsfh4ILB-pXoaExqgXf_bDL_Bqam4m3ADkxIGX7Sl0xMzQm_aini5SOoTQ2V61Zb6tlnJ0yPDfbOBWJDuM9YLaZrg2TNTNYM-jUocfO-Bg0q7m3GsBLVp_IZL6mlU77gR7d1H0Yv/s72-c/NorthwestCorrner.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-9203335629190323954</id><published>2011-09-14T17:40:00.000+05:30</published><updated>2011-10-03T21:00:59.772+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="LPP"/><title type='text'>To implement Simplex method in LPP</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;cview&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgCy8oakkLCz7g1pkont1qCsYUnKW0DcBf3K6eC2ItYUqLgIZawk_3ySQSN7NN6ZnEePs3N4hLCoclA-NGVJbBvuPaefUN0_a-WyoEitH2VowDdwcKtSMtJ1_dhymftI4h-1kXR8nqU3qo/s1600/c+programs.png&quot; width=&quot;0&quot; /&gt;
//To implement Simplex method in LPP&lt;br /&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;conio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int m,n,i,j,k;&lt;br /&gt;
float **a,**B,*cj,*b,*zj,**t,*cb,*x,z=0,*sol;&lt;br /&gt;
int *basic,check=0;&lt;br /&gt;
void inverse(float **t,float **B,float *b,float *x,float **a,int *basic,int m,int n);&lt;br /&gt;
void findzj(float *zj,float **t,float *cb,float *cj,int m ,int n);&lt;br /&gt;
void print(float **t,float *zj,float *cj,float *cb, float *b,int *basic,int m,int n);&lt;br /&gt;
int checkoptmlty(float *zj,int *basic,float **t,int m,int n);&lt;br /&gt;
void gettingoptmlty(float **t,float *zj,float *b,float *cb,float *cj,int *basic,int m,int n);&lt;br /&gt;
int alternate(float **t,float *zj,float *b,float *cb,float *cj,int *basic,int m,int n);&lt;br /&gt;
printf(&quot;\nEnter the number of variable and number of constraints:&quot;);&lt;br /&gt;
scanf(&quot;%d%d&quot;,&amp;amp;n,&amp;amp;m);&lt;br /&gt;
&lt;br /&gt;
/* allocating memory*/&lt;br /&gt;
&amp;nbsp; a=(float**)malloc(m*sizeof(int *));&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; a[i]=(float *)malloc(n*sizeof(float));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; t=(float**)malloc(m*sizeof(int *));&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; t[i]=(float *)malloc(n*sizeof(float));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; cj=(float*)malloc(n*sizeof(float));&lt;br /&gt;
&amp;nbsp; zj=(float*)malloc(n*sizeof(float));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; B=(float**)malloc(m*sizeof(int *));&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; B[i]=(float *)malloc(m*sizeof(float));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; b=(float*)malloc(m*sizeof(float));&lt;br /&gt;
&amp;nbsp; x=(float*)malloc(m*sizeof(float));&lt;br /&gt;
&amp;nbsp; cb=(float*)malloc(m*sizeof(float));&lt;br /&gt;
&amp;nbsp; basic=(int*)malloc(m*sizeof(int));&lt;br /&gt;
&amp;nbsp; sol=(float*)malloc(n*sizeof(float));&lt;br /&gt;
/*memory allocated*/&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; printf(&quot;\nEnter the coefficients of variables in objective function\n&quot;);&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;scanf(&quot;%f&quot;,&amp;amp;cj[i]);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;printf(&quot;\nEnter the coefficients of variables in constraints\n&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;scanf(&quot;%f&quot;,&amp;amp;a[i][j]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;printf(&quot;\nEnter the RHS variables \n&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;scanf(&quot;%f&quot;,&amp;amp;x[i]);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; printf(&quot;\nPlease enter %d the basic variables: you can enter only from &quot;,m);&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;printf(&quot; %d &quot;,i+1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;printf(&quot;\n&quot;);&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;basic[i]);&lt;br /&gt;
&amp;nbsp; basic[i]=basic[i]-1;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; cb[i]=cj[basic[i]];&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;sol[i]=0;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
inverse(t,B,b,x,a,basic,m,n);&lt;br /&gt;
findzj(zj,t,cb,cj,m,n);&lt;br /&gt;
print(t,zj,cj,cb,b,basic,m,n); &lt;br /&gt;
&lt;br /&gt;
while(check==0)&lt;br /&gt;
{&lt;br /&gt;
check=checkoptmlty(zj,basic,t,m,n); &amp;nbsp; &amp;nbsp; &lt;br /&gt;
if(check==0)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nOptimility is not achieved.\n&quot;); &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gettingoptmlty(t,zj,b,cb,cj,basic,m,n);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; inverse(t,B,b,x,a,basic,m,n);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; findzj(zj,t,cb,cj,m,n);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(t,zj,cj,cb,b,basic,m,n); &lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
printf(&quot;\noptimal solution acheived is at :&quot;);&lt;br /&gt;
for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
sol[basic[i]]=b[i];&lt;br /&gt;
for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; printf(&quot; %.2f&quot;,sol[i]);&lt;br /&gt;
&amp;nbsp; z+=cj[i]*sol[i];&lt;br /&gt;
}&lt;br /&gt;
printf(&quot;\n and solution is :%f&quot;,z);&lt;br /&gt;
//checking alternate solution&lt;br /&gt;
if(alternate(t,zj,b,cb,cj,basic,m,n)==1)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; inverse(t,B,b,x,a,basic,m,n);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; findzj(zj,t,cb,cj,m,n);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(t,zj,cj,cb,b,basic,m,n);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; z=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sol[i]=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\noptimal solution acheived is at :&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;sol[basic[i]]=b[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot; %.2f&quot;,sol[i]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;z+=cj[i]*sol[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
printf(&quot;\n and solution is :%f&quot;,z);&lt;br /&gt;
}&lt;br /&gt;
/* freeing allocated memory*/&lt;br /&gt;
&amp;nbsp; free(a);&lt;br /&gt;
&amp;nbsp; free(b);&lt;br /&gt;
&amp;nbsp; free(B);&lt;br /&gt;
&amp;nbsp; free(basic);&lt;br /&gt;
&amp;nbsp; free(cj);&lt;br /&gt;
&amp;nbsp; free(zj);&lt;br /&gt;
&amp;nbsp; free(t);&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&amp;nbsp; getch();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void inverse(float **t,float **B,float *b,float *x,float **a,int *basic,int m,int n)&lt;br /&gt;
{&lt;br /&gt;
float *temp,temp1;&lt;br /&gt;
int i,j,k;&lt;br /&gt;
temp=(float*)malloc(m*sizeof(float));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(k=0;k&amp;lt;m;k++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; B[i][k]=a[i][basic[k]];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;b[i]=x[i];&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; t[i][j]=a[i][j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;for(k=0;k&amp;lt;m;k++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(k!=i)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; for(j=0;j&amp;lt;m;j++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp; &amp;nbsp;if(B[i][j]==B[k][j])&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp; &amp;nbsp;else&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;break;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; if(j==m)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp; printf(&quot;\nDuplicate row\n&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp; getch();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp; exit(0);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;if(B[i][i]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;for(k=i+1;k&amp;lt;m;k++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(B[k][i]!=0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;for(j=0;j&amp;lt;m;j++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; temp1=B[i][j];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; B[i][j]=B[k][j];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; B[k][j]=temp1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;temp1=b[i];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;b[i]=b[k];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;b[k]=temp1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; temp1=t[i][j];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; t[i][j]=t[k][j];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; t[k][j]=temp1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;break;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(k==n)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nInvalid entry\n&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; getch();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; exit(0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; temp1=B[i][i];&lt;br /&gt;
&amp;nbsp; b[i]=(float)b[i]/temp1;&lt;br /&gt;
&amp;nbsp; for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(j&amp;lt;m)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;B[i][j]=(float)B[i][j]/temp1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; t[i][j]=(float)t[i][j]/temp1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;m;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(j!=i)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; temp[j]=B[j][i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(k=0;k&amp;lt;m;k++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(k!=i)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(j&amp;lt;m)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{ B[k][j]=B[k][j]-(temp[k]*B[i][j]); }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;t[k][j]=t[k][j]-(temp[k]*t[i][j]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(k!=i)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; b[k]=b[k]-(temp[k]*b[i]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
free(temp);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void findzj(float *zj,float **t,float *cb,float *cj,int m ,int n)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;int i,j ;&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; zj[i]=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(j=0;j&amp;lt;m;j++) &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;zj[i]+=cb[j]*t[j][i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; zj[i]=zj[i]-cj[i];&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void print(float **t,float *zj,float *cj,float *cb, float *b,int *basic,int m,int n)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; int i,j;&lt;br /&gt;
&amp;nbsp; printf(&quot;\n \t\t object func&quot;);&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;\t%.2f&quot;,cj[i]);&lt;br /&gt;
&amp;nbsp; printf(&quot;\n&quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; printf(&quot;\n \tCb\tbasis\txb&quot;);&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;\tx%d&quot;,i+1);&lt;br /&gt;
&amp;nbsp; printf(&quot;\n&quot;);&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; printf(&quot;\t%.2f\tx%d&quot;,cb[i],basic[i]+1);&lt;br /&gt;
&amp;nbsp; printf(&quot;\t%.2f&quot;,b[i]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;printf(&quot;\t%.2f&quot;,t[i][j]);&lt;br /&gt;
&amp;nbsp; printf(&quot;\n&quot;);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; printf(&quot;\t\tzj-cj\t&quot;);&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; printf(&quot;\t%.2f&quot;,zj[i]);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int checkoptmlty(float *zj,int *basic,float **t,int m,int n)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;int i,j,check;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;// checking unboundedness&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;check=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;m;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(i==basic[j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;check=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;break;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; } &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;} &lt;br /&gt;
&amp;nbsp; &amp;nbsp;if(check==1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;m;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(t[j][i]&amp;gt;0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; break; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;if(j==m &amp;amp;&amp;amp; zj[i]!=0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;printf(&quot;\n Feasible region is unbounded&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;if(zj[i]&amp;lt;0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n solution is unbounded&quot;); &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;getch();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;exit(0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(zj[i]&amp;lt;0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return 0; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;//checking complete&lt;br /&gt;
&amp;nbsp; &amp;nbsp;return 1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void gettingoptmlty(float **t,float *zj,float *b,float *cb,float *cj,int *basic,int m,int n)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;float temp,*p,min,check=0;&lt;br /&gt;
&amp;nbsp;int i,j,loc,ploc=0;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;p=(float*)malloc(m*sizeof(float));&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; min=0;&lt;br /&gt;
&amp;nbsp; loc=0;&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(zj[i]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else if(zj[i]&amp;lt;min) &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;min=zj[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;loc=i;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if(t[i][loc]&amp;lt;=0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; p[i]=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; p[i]=b[i]/t[i][loc]; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; min=1000;&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if(p[i]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min=p[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ploc=i;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; check=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; } &lt;br /&gt;
&amp;nbsp; if(check==0)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;\n Feasible region is unbounded&quot;); &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;getch();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;exit(0); &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; { &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if(p[i]&amp;lt;min &amp;amp;&amp;amp; p[i]!=0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; min=p[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; ploc=i;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; } &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&amp;nbsp; printf(&quot;\n %.1f is selected as pivot element\n&quot;,t[ploc][loc]);&lt;br /&gt;
&amp;nbsp; basic[ploc]=loc;&lt;br /&gt;
&amp;nbsp; cb[ploc]=cj[loc];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int alternate(float **t,float *zj,float *b,float *cb,float *cj,int *basic,int m,int n)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;float temp,*p,min;&lt;br /&gt;
&amp;nbsp;int i,j,loc,ploc=0,check;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;p=(float*)malloc(m*sizeof(float));&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp;// checking alternate solution&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;check=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;m;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(i==basic[j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;check=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;break;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; } &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;} &lt;br /&gt;
&amp;nbsp; &amp;nbsp;if(check==1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;if(zj[i]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;m;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(t[j][i]&amp;gt;0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;break; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(j!=m)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\nalternate solution exits;&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; loc=i; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(t[i][loc]&amp;lt;=0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p[i]=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p[i]=b[i]/t[i][loc]; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; min=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(p[i]==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min=p[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ploc=i;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; } &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{ &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(p[i]&amp;lt;min &amp;amp;&amp;amp; p[i]!=0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; min=p[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ploc=i;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\n %.1f is selected as pivot element\n&quot;,t[ploc][loc]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;basic[ploc]=loc;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;cb[ploc]=cj[loc]; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return 1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;} &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/9203335629190323954/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/09/to-implement-simplex-method-in-lpp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/9203335629190323954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/9203335629190323954'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/09/to-implement-simplex-method-in-lpp.html' title='To implement Simplex method in LPP'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgCy8oakkLCz7g1pkont1qCsYUnKW0DcBf3K6eC2ItYUqLgIZawk_3ySQSN7NN6ZnEePs3N4hLCoclA-NGVJbBvuPaefUN0_a-WyoEitH2VowDdwcKtSMtJ1_dhymftI4h-1kXR8nqU3qo/s72-c/c+programs.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-6350118616575139587</id><published>2011-09-11T22:21:00.000+05:30</published><updated>2011-10-01T16:29:14.957+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="LPP"/><title type='text'>Find the inverse of given matrix using malloc function</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgCy8oakkLCz7g1pkont1qCsYUnKW0DcBf3K6eC2ItYUqLgIZawk_3ySQSN7NN6ZnEePs3N4hLCoclA-NGVJbBvuPaefUN0_a-WyoEitH2VowDdwcKtSMtJ1_dhymftI4h-1kXR8nqU3qo/s1600/c+programs.png&quot; width=&quot;0&quot; /&gt;
&lt;br /&gt;
&lt;div class=&quot;cview&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
float **a,*temp,temp1;&lt;br /&gt;
int i,j,k,n;&lt;br /&gt;
float **b;&lt;br /&gt;
printf(&quot;enter the order of matrix:&quot;);&lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;
&lt;br /&gt;
a=(float**)malloc(n*sizeof(float *));&lt;br /&gt;
for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
a[i]=(float *)malloc(n*sizeof(float));&lt;br /&gt;
b=(float**)malloc(n*sizeof(float *));&lt;br /&gt;
for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
b[i]=(float *)malloc(n*sizeof(float));&lt;br /&gt;
temp=(float *)malloc(n*sizeof(float));&lt;br /&gt;
for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; if(j==i)&lt;br /&gt;
&amp;nbsp; b[i][i]=1;&lt;br /&gt;
&amp;nbsp; else&lt;br /&gt;
&amp;nbsp; b[i][j]=0;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
printf(&quot;\n Enter the matrix\n&quot;);&lt;br /&gt;
for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;printf(&quot;\nEnter the %dth row \n&quot;,i);&lt;br /&gt;
&amp;nbsp;for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; scanf(&quot;%f&quot;,&amp;amp;a[i][j]);&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
printf(&quot;\nEntered a matrix:\n&quot;);&lt;br /&gt;
for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; printf(&quot; %.2f&quot;,a[i][j]);&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;printf(&quot;\n&quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;for(k=0;k&amp;lt;n;k++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(k!=i)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt; &amp;nbsp;if(a[i][j]==a[k][j])&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(j==n)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\nDuplicate row\n&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;getch();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit(0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
if(a[i][i]==0)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;for(k=i+1;k&amp;lt;n;k++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(a[k][i]!=0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt; &amp;nbsp;temp1=a[i][j];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt; &amp;nbsp;a[i][j]=a[k][j];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt; &amp;nbsp;a[k][j]=temp1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt; &amp;nbsp;temp1=b[i][j];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt; &amp;nbsp;b[i][j]=b[k][j];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt; &amp;nbsp;b[k][j]=temp1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;		&lt;/span&gt;break;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(k==n)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp;printf(&quot;\nInvalid entry\n&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp;getch();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt; &amp;nbsp;exit(0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
temp1=a[i][i];&lt;br /&gt;
&amp;nbsp; for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; a[i][j]=a[i][j]/temp1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; b[i][j]=b[i][j]/temp1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(j!=i)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;	&lt;/span&gt;temp[j]=a[j][i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(k=0;k&amp;lt;n;k++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(k!=i)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;a[k][j]=a[k][j]-(temp[k]*a[i][j]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;b[k][j]=b[k][j]-(temp[k]*b[i][j]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
printf(&quot;\n Inverse matrix:\n&quot;);&lt;br /&gt;
for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; printf(&quot; &amp;nbsp;%.2f&quot;,b[i][j]);&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;printf(&quot;\n&quot;);&lt;br /&gt;
}&lt;br /&gt;
printf(&quot;\n matrix A after calculation:\n&quot;);&lt;br /&gt;
for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; printf(&quot; &amp;nbsp;%.2f&quot;,a[i][j]);&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;printf(&quot;\n&quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
getch();&lt;br /&gt;
}&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/6350118616575139587/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/08/find-inverse-of-given-matrix-using.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/6350118616575139587'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/6350118616575139587'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/08/find-inverse-of-given-matrix-using.html' title='Find the inverse of given matrix using malloc function'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgCy8oakkLCz7g1pkont1qCsYUnKW0DcBf3K6eC2ItYUqLgIZawk_3ySQSN7NN6ZnEePs3N4hLCoclA-NGVJbBvuPaefUN0_a-WyoEitH2VowDdwcKtSMtJ1_dhymftI4h-1kXR8nqU3qo/s72-c/c+programs.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-4120473274951380444</id><published>2011-08-31T18:09:00.000+05:30</published><updated>2011-08-31T18:09:16.203+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked List(Self Referential structure)"/><title type='text'>Write a code to solve josephus problem in linked list.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;cview&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//Write a code to solve josephus problem in linked list.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
struct node&lt;br /&gt;
{&lt;br /&gt;
int data;&lt;br /&gt;
struct node *next;&lt;br /&gt;
};&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
struct node *start=NULL;&lt;br /&gt;
int n;&lt;br /&gt;
void create(struct node **, int);&lt;br /&gt;
void josephus(struct node *);&lt;br /&gt;
printf(&quot;Enter the number of elements you want in your linked list :&quot;); &lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;
create(&amp;amp;start,n);&lt;br /&gt;
josephus(start);&lt;br /&gt;
getch(); &amp;nbsp; &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void create(struct node **start,int n)&lt;br /&gt;
{&lt;br /&gt;
int i;&lt;br /&gt;
struct node *lst;&lt;br /&gt;
struct node *p;&lt;br /&gt;
lst=NULL;&lt;br /&gt;
for(i=1;i&amp;lt;=n;i++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;p=(struct node *)malloc(sizeof(struct node));&lt;br /&gt;
&amp;nbsp;printf(&quot;Enter the %d element :&quot;,i);&lt;br /&gt;
&amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;(p-&amp;gt;data));&lt;br /&gt;
&amp;nbsp;if(*start==NULL)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; *start=p;&lt;br /&gt;
&amp;nbsp;else&lt;br /&gt;
&amp;nbsp; &amp;nbsp;lst-&amp;gt;next=p;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;lst=p;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;p-&amp;gt;next=*start;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void josephus(struct node *start)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;struct node *temp,*p;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;int n,count;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\nwhich element you want to delete in josephus problem&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;while(start-&amp;gt;next!=start)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; count=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; p=start;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; while(count&amp;lt;=n-2)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p=p-&amp;gt;next;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; temp=p-&amp;gt;next;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; p-&amp;gt;next=temp-&amp;gt;next;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; free(temp);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; start=p-&amp;gt;next;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;the last item in josephus problem is %d&quot;,start-&amp;gt;data);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/4120473274951380444/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/write-code-to-solve-josephus-problem-in.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/4120473274951380444'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/4120473274951380444'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/write-code-to-solve-josephus-problem-in.html' title='Write a code to solve josephus problem in linked list.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-974616561344109332</id><published>2011-08-31T18:06:00.000+05:30</published><updated>2011-08-31T18:06:30.557+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked List(Self Referential structure)"/><title type='text'>Write a code to create Double Linked List.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;cview&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//Write a code to create Double Linked List.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
struct node&lt;br /&gt;
{&lt;br /&gt;
int data;&lt;br /&gt;
struct node *prev;&lt;br /&gt;
struct node *next;&lt;br /&gt;
};&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
struct node *start=NULL,*end=NULL;&lt;br /&gt;
int n;&lt;br /&gt;
void create(struct node **,struct node **,int);&lt;br /&gt;
void show(struct node *,struct node *);&lt;br /&gt;
void insert_before(struct node **start);&lt;br /&gt;
struct node* search_bitem(struct node *start,int item);&lt;br /&gt;
printf(&quot;Enter the number of elements you want in your linked list :&quot;); &lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;
create(&amp;amp;start,&amp;amp;end,n);&lt;br /&gt;
show(start,end);&lt;br /&gt;
insert_before(&amp;amp;start);&lt;br /&gt;
show(start,end);&lt;br /&gt;
getch(); &amp;nbsp; &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void create(struct node **start,struct node **end,int n)&lt;br /&gt;
{&lt;br /&gt;
int i;&lt;br /&gt;
struct node *lst;&lt;br /&gt;
struct node *p;&lt;br /&gt;
lst=NULL;&lt;br /&gt;
for(i=1;i&amp;lt;=n;i++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;p=(struct node *)malloc(sizeof(struct node));&lt;br /&gt;
&amp;nbsp;printf(&quot;Enter the %d element :&quot;,i);&lt;br /&gt;
&amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;(p-&amp;gt;data));&lt;br /&gt;
&amp;nbsp;p-&amp;gt;next=NULL;&lt;br /&gt;
&amp;nbsp;p-&amp;gt;prev=NULL;&lt;br /&gt;
&amp;nbsp;if(*start==NULL)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; *start=p;&lt;br /&gt;
&amp;nbsp;else&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lst-&amp;gt;next=p;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; p-&amp;gt;prev=lst;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; lst=p;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp; *end=lst;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void show(struct node *start,struct node *end)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;struct node *t;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;t=start;&lt;br /&gt;
printf(&quot;Forwared traversing :\n&quot;);&lt;br /&gt;
while(t!=NULL)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot; %d\n&quot;,t-&amp;gt;data);&lt;br /&gt;
t=t-&amp;gt;next;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
t=end;&lt;br /&gt;
printf(&quot;\nBackward traversing :\n&quot;);&lt;br /&gt;
while(t!=NULL)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot; %d\n&quot;,t-&amp;gt;data);&lt;br /&gt;
t=t-&amp;gt;prev;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void insert_before(struct node **q)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;struct node *p,*loc;&lt;br /&gt;
&amp;nbsp;int item;&lt;br /&gt;
&amp;nbsp;printf(&quot;Enter the item before which new element is to be inserted &quot;);&lt;br /&gt;
&amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;item);&lt;br /&gt;
&amp;nbsp;if(*q==NULL)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; printf(&quot;\nItem before which element is to be inserted is not in the list&quot;);&lt;br /&gt;
&amp;nbsp; return;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; p=(struct node *)malloc(sizeof(struct node));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;Enter the element to be inserted &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;(p-&amp;gt;data));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; p-&amp;gt;next=NULL;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; p-&amp;gt;prev=NULL;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp;if(item==(*q)-&amp;gt;data)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; (*q)-&amp;gt;prev=p;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; p-&amp;gt;next=*q;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; *q=p;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;else&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp;loc=(struct node *)search_bitem(*q,item);&lt;br /&gt;
&amp;nbsp; if(loc==NULL)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;\nItem before which element is to be inserted is not in the list&quot;);&lt;br /&gt;
&amp;nbsp; else&lt;br /&gt;
&amp;nbsp; { &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; p-&amp;gt;next=loc-&amp;gt;next;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; p-&amp;gt;prev=loc;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; (loc-&amp;gt;next)-&amp;gt;prev=p;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; loc-&amp;gt;next=p;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
struct node* search_bitem(struct node *start,int item)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;struct node *prev,*ptr;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ptr=start;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; prev=ptr;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ptr=ptr-&amp;gt;next;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(ptr!=NULL)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(item==(ptr-&amp;gt;data))&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return prev;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; prev=ptr;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ptr=ptr-&amp;gt;next;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return NULL;&lt;br /&gt;
}&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/974616561344109332/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/writw-code-to-create-double-linked-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/974616561344109332'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/974616561344109332'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/writw-code-to-create-double-linked-list.html' title='Write a code to create Double Linked List.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-3570891140532913214</id><published>2011-08-31T18:05:00.000+05:30</published><updated>2011-08-31T18:05:18.876+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked List(Self Referential structure)"/><title type='text'>Create a circular linked list.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;cview&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//Create a circular linked list.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
struct node&lt;br /&gt;
{&lt;br /&gt;
int data;&lt;br /&gt;
struct node *next;&lt;br /&gt;
};&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
struct node *start=NULL;&lt;br /&gt;
int n;&lt;br /&gt;
void create(struct node **, int);&lt;br /&gt;
void show(struct node *);&lt;br /&gt;
printf(&quot;Enter the number of elements you want in your linked list :&quot;); &lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;
create(&amp;amp;start,n);&lt;br /&gt;
show(start);&lt;br /&gt;
getch(); &amp;nbsp; &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void create(struct node **start,int n)&lt;br /&gt;
{&lt;br /&gt;
int i;&lt;br /&gt;
struct node *lst;&lt;br /&gt;
struct node *p,*head;&lt;br /&gt;
head=(struct node *)malloc(sizeof(struct node));&lt;br /&gt;
*start=head;&lt;br /&gt;
head-&amp;gt;next=head;&lt;br /&gt;
lst=NULL;&lt;br /&gt;
for(i=1;i&amp;lt;=n;i++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;p=(struct node *)malloc(sizeof(struct node));&lt;br /&gt;
&amp;nbsp;printf(&quot;Enter the %d element :&quot;,i);&lt;br /&gt;
&amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;(p-&amp;gt;data));&lt;br /&gt;
&amp;nbsp;p-&amp;gt;next=*start;&lt;br /&gt;
&amp;nbsp;if((*start)-&amp;gt;next==*start)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; (*start)-&amp;gt;next=p;&lt;br /&gt;
&amp;nbsp;else&lt;br /&gt;
&amp;nbsp; &amp;nbsp;lst-&amp;gt;next=p;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;lst=p;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void show(struct node *start)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;struct node *temp;&lt;br /&gt;
printf(&quot;Entered linked list is :\n&quot;);&lt;br /&gt;
temp=start-&amp;gt;next;&lt;br /&gt;
while(temp!=start)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot; %d\n&quot;,temp-&amp;gt;data);&lt;br /&gt;
temp=temp-&amp;gt;next;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/3570891140532913214/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/wap-to-create-circular-linked-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/3570891140532913214'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/3570891140532913214'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/wap-to-create-circular-linked-list.html' title='Create a circular linked list.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-5057202723470267320</id><published>2011-08-31T18:01:00.000+05:30</published><updated>2011-08-31T18:01:18.696+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><title type='text'>How to find majority element in array without using backtracking method.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;cview&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//How to find majority element in array without using backtracking method.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;int *p,*q,n,i,j,c=0,f,fl=0;&lt;br /&gt;
&amp;nbsp;printf(&quot;Enter the number of elments you want in your array list: &quot;);&lt;br /&gt;
&amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;
&amp;nbsp;p=(int *)malloc(n*sizeof(int));&lt;br /&gt;
&amp;nbsp;q=(int *)malloc(n*sizeof(int));&lt;br /&gt;
&amp;nbsp;printf(&quot;\n Enter the value of array elements \n&quot;);&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;p[i]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; q[i]=p[i];&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;=n/2;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; c=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;if(p[i]==-1000)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=i+1;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(p[i]==p[j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;c=c+1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p[j]=-1000;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;if(c&amp;gt;(n/2))&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; fl=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;%d is majority element&quot;,p[i]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; break;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
if(fl==0)&lt;br /&gt;
printf(&quot;no majority element is found&quot;);&lt;br /&gt;
} &lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/5057202723470267320/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-find-majority-element-in-array_11.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/5057202723470267320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/5057202723470267320'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-find-majority-element-in-array_11.html' title='How to find majority element in array without using backtracking method.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-2753204483294714738</id><published>2011-08-31T18:00:00.000+05:30</published><updated>2011-08-31T18:00:12.921+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><title type='text'>How to find majority element in array using backtracking method.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;cview&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//How to find majority element in array using backtracking method.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;int *p,n,i,j,c=0,f,fl=0;&lt;br /&gt;
&amp;nbsp;printf(&quot;Enter the number of elments you want in your array list: &quot;);&lt;br /&gt;
&amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;
&amp;nbsp;p=(int *)malloc(n*sizeof(int));&lt;br /&gt;
&amp;nbsp;printf(&quot;\n Enter the value of array elements \n&quot;);&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;p[i]);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;=n/2;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;f=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;c=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;i;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(p[i]==p[j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; f=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;if(f==1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;c=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=i+1;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(p[i]==p[j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;c=c+1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;if(c&amp;gt;(n/2))&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; fl=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;%d is majority element&quot;,p[i]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; break;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
if(fl==0)&lt;br /&gt;
printf(&quot;no majority element is found&quot;);&lt;br /&gt;
} &lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/2753204483294714738/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-find-majority-element-in-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/2753204483294714738'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/2753204483294714738'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-find-majority-element-in-array.html' title='How to find majority element in array using backtracking method.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-1023187525198252523</id><published>2011-08-31T17:54:00.002+05:30</published><updated>2011-08-31T17:56:30.064+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked List(Self Referential structure)"/><title type='text'>How to create linked list(self referential structure) and perform insert operaton on it.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;cview&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//How to create linked list(self referential structure) and perform insert operaton on it.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
struct node&lt;br /&gt;
{&lt;br /&gt;
int data;&lt;br /&gt;
struct node *next;&lt;br /&gt;
};&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
struct node *p;&lt;br /&gt;
char c;&lt;br /&gt;
int n;&lt;br /&gt;
void create(struct node **, int);&lt;br /&gt;
void show(struct node *);&lt;br /&gt;
void insert(struct node **);&lt;br /&gt;
p=NULL;&lt;br /&gt;
printf(&quot;Enter the elements you want in your linked list :&quot;); &lt;br /&gt;
scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;
create(&amp;amp;p,n);&lt;br /&gt;
show(p);&lt;br /&gt;
fflush(stdin);&lt;br /&gt;
printf(&quot;\nWould you like to insert element in the begining of linked list Y/N:&quot;);&lt;br /&gt;
scanf(&quot; %c&quot;,&amp;amp;c);&lt;br /&gt;
if(c==&#39;y&#39;||c==&#39;Y&#39;)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;insert(&amp;amp;p);&lt;br /&gt;
&amp;nbsp;show(p);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
void create(struct node **q,int n)&lt;br /&gt;
{&lt;br /&gt;
int i;&lt;br /&gt;
struct node *lst;&lt;br /&gt;
struct node *p;&lt;br /&gt;
lst=NULL;&lt;br /&gt;
for(i=1;i&amp;lt;=n;i++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;p=(struct node *)malloc(sizeof(struct node));&lt;br /&gt;
&amp;nbsp;printf(&quot;Enter the %d element :&quot;,i);&lt;br /&gt;
&amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;(p-&amp;gt;data));&lt;br /&gt;
&amp;nbsp;p-&amp;gt;next=NULL;&lt;br /&gt;
&amp;nbsp;if(*q==NULL)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; *q=p;&lt;br /&gt;
&amp;nbsp;else&lt;br /&gt;
&amp;nbsp; &amp;nbsp;lst-&amp;gt;next=p;&lt;br /&gt;
&amp;nbsp; lst=p;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
void show(struct node *start)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot;Entered linked list is :\n&quot;);&lt;br /&gt;
while(start!=NULL)&lt;br /&gt;
{&lt;br /&gt;
printf(&quot; %d\n&quot;,start-&amp;gt;data);&lt;br /&gt;
start=start-&amp;gt;next;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
void insert(struct node **q)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;struct node *p;&lt;br /&gt;
&amp;nbsp;struct node *start;&lt;br /&gt;
&amp;nbsp;start=*q;&lt;br /&gt;
&amp;nbsp;p=(struct node *)malloc(sizeof(struct node));&lt;br /&gt;
&amp;nbsp;printf(&quot;Enter the element to be inserted &quot;);&lt;br /&gt;
&amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;(p-&amp;gt;data));&lt;br /&gt;
&amp;nbsp;p-&amp;gt;next=start;&lt;br /&gt;
&amp;nbsp;*q=p;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/1023187525198252523/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-create-linked-listself.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/1023187525198252523'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/1023187525198252523'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-create-linked-listself.html' title='How to create linked list(self referential structure) and perform insert operaton on it.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-1817790033334055669</id><published>2011-08-31T17:52:00.000+05:30</published><updated>2011-08-31T17:52:59.838+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><title type='text'>How to traverse the array using C++.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;cppview&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//How to traverse the array using C++.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;int i, k, data[50], n, lb, ub;&lt;br /&gt;
&amp;nbsp;clrscr();&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the number of elements in the array:&quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;n;&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the value of &quot;&amp;lt;&amp;lt;n&amp;lt;&amp;lt;&quot; elements:&quot;;&lt;br /&gt;
&amp;nbsp;for(i=0; i&amp;lt;n; i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;cin&amp;gt;&amp;gt;data[i];&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;lb=0;&lt;br /&gt;
&amp;nbsp;ub=n-1;&lt;br /&gt;
&amp;nbsp;for(k=lb; k&amp;lt;=ub; k++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;k&amp;lt;&amp;lt;&quot; element is &quot;&amp;lt;&amp;lt;data[k];&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;getch();&lt;br /&gt;
}&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/1817790033334055669/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-traverse-array-using-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/1817790033334055669'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/1817790033334055669'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-traverse-array-using-c.html' title='How to traverse the array using C++.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-6886479761074997551</id><published>2011-08-27T18:06:00.000+05:30</published><updated>2011-08-27T18:06:44.190+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><title type='text'>How to calculate Sum of two matrix using C++.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;cppview&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//How to calculate Sum of two matrix using C++.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;int a[10][10], b[10][10] , c[10][10];&lt;br /&gt;
&amp;nbsp;int i, j, m, n;&lt;br /&gt;
&amp;nbsp;clrscr();&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;enter the order of matrix a and b: &quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;m&amp;gt;&amp;gt;n;&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Elements of a matrix:&quot;;&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;cin&amp;gt;&amp;gt;a[i][j];&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Elements of b matrix:&quot;;&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;cin&amp;gt;&amp;gt;b[i][j];&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot; a &amp;nbsp;matrix is :&quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp; for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;cout&amp;lt;&amp;lt;&quot; &quot;&amp;lt;&amp;lt;a[i][j];&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot; b &amp;nbsp;matrix is :&quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp; for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;cout&amp;lt;&amp;lt;&quot; &quot;&amp;lt;&amp;lt;b[i][j];&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;c[i][j]=a[i][j] + b[i][j];&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Sum of two matrix is:&quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp; for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;cout&amp;lt;&amp;lt;&quot; &quot;&amp;lt;&amp;lt;c[i][j];&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;getch();&lt;br /&gt;
}&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/6886479761074997551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-calculate-sum-of-two-matrix.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/6886479761074997551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/6886479761074997551'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-calculate-sum-of-two-matrix.html' title='How to calculate Sum of two matrix using C++.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-7078992368282549263</id><published>2011-08-27T18:05:00.001+05:30</published><updated>2011-08-27T18:10:34.871+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Sorting"/><title type='text'>How to sort an array using  selection sort in C++.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;cppview&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//Program to sort an array using &amp;nbsp;selection sort in C++.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;int a[50], n, temp, k , loc, i;&lt;br /&gt;
&amp;nbsp;int min, j;&lt;br /&gt;
&amp;nbsp;clrscr();&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the number of elements in array: &quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;n;&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;The array :&quot;;&lt;br /&gt;
&amp;nbsp;for (i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cin&amp;gt;&amp;gt;a[i];&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;for (k=0; k&amp;lt;n-1; k++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; min=a[k];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; loc=k;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for (j=k+1; j&amp;lt;n; j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;if(min&amp;gt;a[j])&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;min=a[j];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;loc=j;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;temp=a[k];&lt;br /&gt;
&amp;nbsp; &amp;nbsp;a[k]=a[loc];&lt;br /&gt;
&amp;nbsp; &amp;nbsp;a[loc]=temp;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;The sorted array is: &quot;;&lt;br /&gt;
&amp;nbsp;for (i=0; i&amp;lt;n; i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;a[i]&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;getch();&lt;br /&gt;
}&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/7078992368282549263/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-sort-array-using-selection-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/7078992368282549263'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/7078992368282549263'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-sort-array-using-selection-sort.html' title='How to sort an array using  selection sort in C++.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-1685101335843735802</id><published>2011-08-27T18:04:00.001+05:30</published><updated>2011-08-27T18:12:24.352+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Sorting"/><title type='text'>Program to sort an array using  Radix sort in C++.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;cppview&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//Program to sort an array using &amp;nbsp;Radix sort in C++.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;int a[50],i,n;&lt;br /&gt;
&amp;nbsp;void radixsort(int[],int);&lt;br /&gt;
&amp;nbsp;clrscr();&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot; Enter the number of elements in array: &quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;n;&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;enter the elements of array: &quot;;&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cin&amp;gt;&amp;gt;a[i];&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;radixsort(a,n);&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;The sorted array is as follow:&quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;a[i]&amp;lt;&amp;lt;&quot; &quot;;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;getch();&lt;br /&gt;
}&lt;br /&gt;
void radixsort(int a[],int n)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;int bucket[10][20],bucketcount[10];&lt;br /&gt;
&amp;nbsp;int i,j,k,r,digitcount=0,divisor=1,largest,passno;&lt;br /&gt;
&amp;nbsp;largest=a[0];&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; if(a[i]&amp;gt;largest)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;largest=a[i];&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;while(largest&amp;gt;0)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; digitcount++;&lt;br /&gt;
&amp;nbsp; largest=largest/10;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;for(passno=0;passno&amp;lt;digitcount;passno++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; for(k=0;k&amp;lt;10;k++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;bucketcount[k]=0;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; r=(a[i]/divisor)%10;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; bucket[r][bucketcount[r]++]=a[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp;i=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(k=0;k&amp;lt;10;k++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;bucketcount[k];j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a[i]=bucket[k][j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;i++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; divisor=divisor*10;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/1685101335843735802/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/program-to-sort-array-using-radix-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/1685101335843735802'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/1685101335843735802'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/program-to-sort-array-using-radix-sort.html' title='Program to sort an array using  Radix sort in C++.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-4941680442725153006</id><published>2011-08-27T18:02:00.000+05:30</published><updated>2011-08-27T18:02:49.926+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><title type='text'>Program to calculate multiplication of two matrix using C++.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;cppview&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//Program to calculate multiplication of two matrix using C++.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;int a[10][10],b[10][10],c[10][10],i,j,k;&lt;br /&gt;
&amp;nbsp;int m, n, p, q;&lt;br /&gt;
&amp;nbsp;clrscr();&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the number of rows in A matrix: &quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;m;&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the number of columns in A matrix: &quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;n;&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the number of rows in B matrix: &quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;p;&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the number of rows in B matrix: &quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;q;&lt;br /&gt;
&amp;nbsp;if(n==p)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Elements of a matrix:&quot;;&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; cin&amp;gt;&amp;gt;a[i][j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Elements of b matrix:&quot;;&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;p;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;q;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; cin&amp;gt;&amp;gt;b[i][j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;q;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; c[i][j]=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for(k=0;k&amp;lt;n;k++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;c[i][j]+=a[i][k]*b[k][j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot; a matrix: &quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;cout&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; cout&amp;lt;&amp;lt;&quot; &quot;&amp;lt;&amp;lt;a[i][j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot; b matrix:&quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;p;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;cout&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;q;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; cout&amp;lt;&amp;lt;&quot; &quot;&amp;lt;&amp;lt;b[i][j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot; mul of two matrix&quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp; for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;cout&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(j=0;j&amp;lt;q;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; cout&amp;lt;&amp;lt;&quot; &quot;&amp;lt;&amp;lt;c[i][j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;else&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Multiplication is not possible &quot;;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;getch();&lt;br /&gt;
}&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/4941680442725153006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/program-to-calculate-multiplication-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/4941680442725153006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/4941680442725153006'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/program-to-calculate-multiplication-of.html' title='Program to calculate multiplication of two matrix using C++.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-2816705046853429078</id><published>2011-08-27T18:00:00.000+05:30</published><updated>2011-08-27T18:00:09.338+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><title type='text'>Program to find sum of each row and column and total of matrix.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;cppview&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//Program to find sum of each row and column and total of matrix.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;iomanip.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;int a[10][10],i,j, m, n;&lt;br /&gt;
&amp;nbsp;clrscr();&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot; Enter the rows of matrix: &quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;m;&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the column of matrix: &quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;n;&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Elements of a matrix:&quot;;&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;m;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;cin&amp;gt;&amp;gt;a[i][j];&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;for(i=0; i&amp;lt;m; i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; a[i][n]=0;&lt;br /&gt;
&amp;nbsp; for(j=0; j&amp;lt;n; j++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; a[i][n]+=a[i][j];&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;for(j=0; j&amp;lt;n; j++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; a[m][j]=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for (i=0; i&amp;lt;m; i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; a[m][j]+=a[i][j];&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;a[m][n]=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;for(i=0; i&amp;lt;m ; i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;a[m][n]+=a[i][n];&lt;br /&gt;
&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot; a matrix is :&quot;&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;m+1;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;endl;&lt;br /&gt;
&amp;nbsp; for(j=0;j&amp;lt;n+1;j++)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;cout&amp;lt;&amp;lt;setw(5)&amp;lt;&amp;lt;&quot; &quot;&amp;lt;&amp;lt;a[i][j];&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;getch();&lt;br /&gt;
}&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/2816705046853429078/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/program-to-find-sum-of-each-row-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/2816705046853429078'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/2816705046853429078'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/program-to-find-sum-of-each-row-and.html' title='Program to find sum of each row and column and total of matrix.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-4367685772724205339</id><published>2011-08-27T17:57:00.000+05:30</published><updated>2011-08-27T17:57:42.880+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><title type='text'>How to linearly search an element in array using C++.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;cppview&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//Program to linearly search an element in array using C++.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;int i, k, loc, item, data[50], n;&lt;br /&gt;
&amp;nbsp;clrscr();&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;&quot;Enter the number of elements in the array:&quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;n;&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;&quot;Enter the value of &quot;&amp;lt;&amp;lt;n&amp;lt;&amp;lt;&quot; elements:&quot;;&lt;br /&gt;
&amp;nbsp;for(i=0; i&amp;lt;n; i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cin&amp;gt;&amp;gt;data[i];&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;loc=-1;&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the given element&quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;item;&lt;br /&gt;
&amp;nbsp;for(k=0; k&amp;lt;n; k++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; if(data[k]==item)&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;loc=k;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;if(loc==-1)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Given element is not present&quot;;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;else&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Given element is present at location=&quot;&amp;lt;&amp;lt;loc;&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;getch();&lt;br /&gt;
}&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/4367685772724205339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-linearly-search-element-in-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/4367685772724205339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/4367685772724205339'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-linearly-search-element-in-array.html' title='How to linearly search an element in array using C++.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-3560005397916373551</id><published>2011-08-27T17:52:00.000+05:30</published><updated>2011-08-27T17:52:57.390+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><title type='text'>How to find the Largest element in array using C++.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;cppview&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//Program to find the Largest element in array using C++.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;int i, k, loc, max, data[50], n;&lt;br /&gt;
&amp;nbsp;clrscr();&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the number of elements in the array:&quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;n;&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the value of &quot;&amp;lt;&amp;lt;n&amp;lt;&amp;lt;&quot; elements:&quot;;&lt;br /&gt;
&amp;nbsp;for(i=0; i&amp;lt;n; i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cin&amp;gt;&amp;gt;data[i];&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;loc=0;&lt;br /&gt;
&amp;nbsp;max=data[0];&lt;br /&gt;
&amp;nbsp;for(k=0; k&amp;lt;n; k++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; if(max&amp;lt;data[k])&lt;br /&gt;
&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;loc=k;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;max=data[k];&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Largest element is &quot;&amp;lt;&amp;lt;max&amp;lt;&amp;lt;&quot; and its location is &quot;&amp;lt;&amp;lt;loc;&lt;br /&gt;
&amp;nbsp;getch();&lt;br /&gt;
}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/3560005397916373551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-find-largest-element-in-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/3560005397916373551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/3560005397916373551'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-find-largest-element-in-array.html' title='How to find the Largest element in array using C++.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-329495468431377207</id><published>2011-08-27T17:51:00.000+05:30</published><updated>2011-08-27T17:51:16.248+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><title type='text'>How to insert a new element in array using C++.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;cppview&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//Program to insert a new element in array using C++.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;int i, k, j, item, data[50], n;&lt;br /&gt;
&amp;nbsp;clrscr();&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the number of elements in the array:&quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;n;&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the value of &quot;&amp;lt;&amp;lt;n&amp;lt;&amp;lt;&quot; elements:&quot;;&lt;br /&gt;
&amp;nbsp;for(i=0; i&amp;lt;n; i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp;cin&amp;gt;&amp;gt;data[i];&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot; Enter the location of item:&quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;k;&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the value of item:&quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;item;&lt;br /&gt;
&amp;nbsp;for(j=n-1; j&amp;gt;=k; j--)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; data[j+1]=data[j];&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;data[k]=item;&lt;br /&gt;
&amp;nbsp;n=n+1;&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;i&amp;lt;&amp;lt;&quot; element is:&quot;&amp;lt;&amp;lt;data[i];&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;getch();&lt;br /&gt;
}&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/329495468431377207/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-insert-new-element-in-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/329495468431377207'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/329495468431377207'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-insert-new-element-in-array.html' title='How to insert a new element in array using C++.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-3020985209828792596</id><published>2011-08-21T17:04:00.000+05:30</published><updated>2011-08-21T17:04:00.323+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><title type='text'>Program to create lower triangular matrix.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;cview&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//Program to create lower triangular matrix.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
void create(int **t,int n,int r);&lt;br /&gt;
void print(int *t,int n);&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; int *a,ele,r;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;how many rows you want in lower triangular matrix :&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;r);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; ele=(r*(r+1))/2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; create(&amp;amp;a,ele,r);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; print(a,r);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; getch();&lt;br /&gt;
}&lt;br /&gt;
void create(int **t,int n,int r)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;int p,q,i,j,k,*a,*b,m=0,f,c=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\nEnter the element of lower triangular matrix&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;a=(int*)malloc(n*sizeof(int));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;b=(int*)malloc(n*sizeof(int));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;for(p=0;p&amp;lt;n;p++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; f=0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\nEnter the postion row and column of element:&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d%d&quot;,&amp;amp;i,&amp;amp;j);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if(j&amp;gt;i||i&amp;gt;=r)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\nYou have entered the wrong poition of element.Try again&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p=p-1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; k=(i*(i+1))/2+j;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; for(q=0;q&amp;lt;m;q++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(b[q]==k)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;f=1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;break;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if(f==1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\nAt the given postion you already entered the data. Do you want to override it? if YES press 1 if NO press 0&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;c);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;p=p-1;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(c==1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\nEnter the value: &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;a[k]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;b[m]=k;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;m++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\nEnter the value: &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;a[k]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*t=a;&lt;br /&gt;
}&lt;br /&gt;
void print(int *t,int n)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;int i,j,k;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; for(j=0;j&amp;lt;=i;j++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;k=(i*(i+1))/2+j;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;%d &quot;,t[k]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/3020985209828792596/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/program-to-create-lower-triangular.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/3020985209828792596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/3020985209828792596'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/program-to-create-lower-triangular.html' title='Program to create lower triangular matrix.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-7703762967929100129</id><published>2011-08-21T17:02:00.000+05:30</published><updated>2011-08-21T17:02:52.178+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java Programs"/><category scheme="http://www.blogger.com/atom/ns#" term="Operators"/><title type='text'>BitwiseOperator in java</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhESwOf6_pLy5dvVgbyj0I2wBexlJdbZ72SSGvq78xx_7PNakBaLmiUOTKjq79rOgSLy_99APQ-W3996mhYTTLTE-JV4oKo89tvWCSL4ru7EzkBZEgTZuX3fA7xx2FtYuvxAxfPlpOaw58B/s1600/java.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;javaview&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red; font-family: Arial, sans-serif; font-size: 12px; line-height: 18px;&quot;&gt;//BitwiseOperator in java&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, sans-serif; font-size: 12px; line-height: 18px;&quot;&gt;class BitwiseOperator&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial, sans-serif; font-size: 9pt; line-height: 150%;&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial, sans-serif; font-size: 9pt; line-height: 150%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String arg[])&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial, sans-serif; font-size: 9pt; line-height: 150%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial, sans-serif; font-size: 9pt; line-height: 150%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int a=3,b=5,c=-8,d=-2;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial, sans-serif; font-size: 9pt; line-height: 150%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;a&amp;amp;b=&amp;nbsp; &quot;+(a&amp;amp;b));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial, sans-serif; font-size: 9pt; line-height: 150%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;a|b=&amp;nbsp; &quot;+(a|b));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial, sans-serif; font-size: 9pt; line-height: 150%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;a^b= &amp;nbsp;&quot;+(a^b));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial, sans-serif; font-size: 9pt; line-height: 150%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;~a=&amp;nbsp; &quot;+~a);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial, sans-serif; font-size: 9pt; line-height: 150%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;a&amp;lt;&amp;lt;1=&amp;nbsp; &quot;+(a&amp;lt;&amp;lt;1));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial, sans-serif; font-size: 9pt; line-height: 150%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;d&amp;lt;&amp;lt;2=&amp;nbsp; &quot;+(d&amp;lt;&amp;lt;2));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial, sans-serif; font-size: 9pt; line-height: 150%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;c&amp;gt;&amp;gt;2=&amp;nbsp; &quot;+(c&amp;gt;&amp;gt;2));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial, sans-serif; font-size: 9pt; line-height: 150%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;c&amp;gt;&amp;gt;&amp;gt;2=&amp;nbsp; &quot;+(c&amp;gt;&amp;gt;&amp;gt;2));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial, sans-serif; font-size: 9pt; line-height: 150%;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 150%; margin-bottom: .0001pt; margin-bottom: 0cm;&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;font-family: Arial, sans-serif; font-size: 9pt; line-height: 150%;&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/7703762967929100129/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/08/bitwiseoperator-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/7703762967929100129'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/7703762967929100129'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/08/bitwiseoperator-in-java.html' title='BitwiseOperator in java'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhESwOf6_pLy5dvVgbyj0I2wBexlJdbZ72SSGvq78xx_7PNakBaLmiUOTKjq79rOgSLy_99APQ-W3996mhYTTLTE-JV4oKo89tvWCSL4ru7EzkBZEgTZuX3fA7xx2FtYuvxAxfPlpOaw58B/s72-c/java.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-8142486385548878398</id><published>2011-08-21T17:00:00.001+05:30</published><updated>2011-08-21T17:01:41.446+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="CPP Program"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><title type='text'>How to remove an element in array using C++.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;cppview&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//How to remove an element in array using C++.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;int i, k, j, item, data[50], n;&lt;br /&gt;
&amp;nbsp;clrscr();&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;&quot;Enter the number of elements in the array:&quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;n;&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the value of &quot;&amp;lt;&amp;lt;n&amp;lt;&amp;lt;&quot; elements:&quot;;&lt;br /&gt;
&amp;nbsp;for(i=0; i&amp;lt;n; i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cin&amp;gt;&amp;gt;data[i];&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot; Enter the location of item to be deleted:&quot;;&lt;br /&gt;
&amp;nbsp;cin&amp;gt;&amp;gt;k;&lt;br /&gt;
&amp;nbsp;for(j=k;j&amp;lt;n-1; j++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; data[j]=data[j+1];&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;n=n-1;&lt;br /&gt;
&amp;nbsp;for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;i&amp;lt;&amp;lt;&quot; element is:&quot;&amp;lt;&amp;lt;data[i];&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&amp;nbsp;getch();&lt;br /&gt;
}&lt;br /&gt;
&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/8142486385548878398/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-remove-element-in-array-using-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/8142486385548878398'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/8142486385548878398'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-remove-element-in-array-using-c.html' title='How to remove an element in array using C++.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-9187371296403032054</id><published>2011-08-21T16:58:00.002+05:30</published><updated>2011-08-27T18:14:18.746+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="CPP Program"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Searching"/><title type='text'>Program to search an element in array using Binary search in C++.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;cppview&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;//Program to search an element in array using Binary search in C++.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;void main()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp;int i, beg, end, loc, mid, item, data[50], n;&lt;/div&gt;&lt;div&gt;&amp;nbsp;clrscr();&lt;/div&gt;&lt;div&gt;&amp;nbsp;cout&amp;lt;&amp;lt;&quot;Enter the number of elements in the array:&quot;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;cin&amp;gt;&amp;gt;n;&lt;/div&gt;&lt;div&gt;&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot; Enter the value of &quot;&amp;lt;&amp;lt;n&amp;lt;&amp;lt;&quot; elements:&quot;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;for(i=0; i&amp;lt;n; i++)&lt;/div&gt;&lt;div&gt;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;cin&amp;gt;&amp;gt;data[i];&lt;/div&gt;&lt;div&gt;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;beg=0;&lt;/div&gt;&lt;div&gt;&amp;nbsp;end=n-1;&lt;/div&gt;&lt;div&gt;&amp;nbsp;mid=int((beg+end)/2);&lt;/div&gt;&lt;div&gt;&amp;nbsp;cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot; Enter the given element&quot;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;cin&amp;gt;&amp;gt;item;&lt;/div&gt;&lt;div&gt;&amp;nbsp;while(beg&amp;lt;=end &amp;amp;&amp;amp; data[mid]!=item)&lt;/div&gt;&lt;div&gt;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; if(item&amp;lt;data[mid])&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;end=mid-1;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; else&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;beg=mid+1;&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; mid=int((beg+end)/2);&lt;/div&gt;&lt;div&gt;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;if(data[mid]==item)&lt;/div&gt;&lt;div&gt;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; loc=mid;&lt;/div&gt;&lt;div&gt;&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Element found at location:&quot;&amp;lt;&amp;lt;loc;&lt;/div&gt;&lt;div&gt;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;else&lt;/div&gt;&lt;div&gt;&amp;nbsp;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Element is not found&quot;;&lt;/div&gt;&lt;div&gt;&amp;nbsp;}&lt;/div&gt;&lt;div&gt;&amp;nbsp;getch();&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/9187371296403032054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/program-to-search-element-in-array_11.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/9187371296403032054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/9187371296403032054'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/program-to-search-element-in-array_11.html' title='Program to search an element in array using Binary search in C++.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9050761206169980588.post-367741572094791049</id><published>2011-08-21T16:53:00.002+05:30</published><updated>2011-08-27T18:28:56.971+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="CPP Program"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Sorting"/><title type='text'>How to Sort array in c++ using Bubble sort.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;cppview&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;0px&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s1600/Data+Structure.png&quot; width=&quot;0px&quot; /&gt;//How to Sort array in c++ using Bubble sort.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;iostream.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;void main()&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;&amp;nbsp; int a[40],n,i,t,k;&lt;/div&gt;&lt;div&gt;&amp;nbsp; clrscr();&lt;/div&gt;&lt;div&gt;&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the no. of element in the array: &quot;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; cin&amp;gt;&amp;gt;n;&lt;/div&gt;&lt;div&gt;&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;Enter the values of &quot;&amp;lt;&amp;lt;n&amp;lt;&amp;lt;&quot; elements: &quot;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; cin&amp;gt;&amp;gt;a[i];&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; for(k=0;k&amp;lt;n-1;k++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;n-1-k;i++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if(a[i]&amp;gt;a[i+1])&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;t=a[i];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a[i]=a[i+1];&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;a[i+1]=t;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;&quot;The sorted array is:&quot;;&lt;/div&gt;&lt;div&gt;&amp;nbsp; for(i=0;i&amp;lt;n;i++)&lt;/div&gt;&lt;div&gt;&amp;nbsp; {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;a[i];&lt;/div&gt;&lt;div&gt;&amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; getch();&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://prgskills.blogspot.com/feeds/367741572094791049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-sort-array-in-c-using-bubble.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/367741572094791049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9050761206169980588/posts/default/367741572094791049'/><link rel='alternate' type='text/html' href='http://prgskills.blogspot.com/2011/07/how-to-sort-array-in-c-using-bubble.html' title='How to Sort array in c++ using Bubble sort.'/><author><name>Bimalpreet Singh</name><uri>http://www.blogger.com/profile/13864174856316177710</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpDp5sZUaJvYUJt8bVXZ-nZ1dVEf4UA4p1ts9EDFWBkG-221FMcidHyX0Bi26EYRtgRFXm5JncDZuLI4nK-gWNQZTKvcLprE6DQ2AcKsgv7nDuhZBLXLuuu_Qi1joGa3Q/s1600/BimalpreetSingh.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoYYy6Wks9ZvNGuh61L3whBLGiT4xUSTnOFfMfAWFLtKb4By2F0ZMwzuBXMTyzxA57TuV6VjhS9z7_m51di0XCBj4eCddnsK3TtzpYqOhYnAOhEq6_R0Rm_hNT7rrzy3kiMHN_9vdW8_KO/s72-c/Data+Structure.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>