tag:blogger.com,1999:blog-37704997297201578462024-03-05T18:08:39.400-08:00C++ ProgrammingWelcome to " way2cplusplus.blogspot.in " Objective of this blog is to implement various Computer Science Engineering Lab problems into C++ programming language. These are basically most common Lab Exercise problems based on the curriculum of engineering colleges throughout the Nation. These lab exercises are also relevant to Data structure. Simply C++ programming zone...Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.comBlogger56125tag:blogger.com,1999:blog-3770499729720157846.post-31534047757904432602014-05-03T03:54:00.003-07:002014-05-03T03:56:28.092-07:00Floyd Warshall (all pair shortest path )<u><b>Source Code:</b></u><span style="color: #cc0000;"> </span><br />
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #cc0000;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2O18C7hw1D3zRvsxexAaCa_Jl7jnP-3zckMA0NKQ_dXvIqD4JHD-RUBfg3dp00BPzRGXDo25Pca3fH9AMsITZthOINp75yfxvpvmIZj4wNxpHqUu_BhN2OxnWXe79xgn14sMRdYEECzjK/s1600/floyd+warshall.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2O18C7hw1D3zRvsxexAaCa_Jl7jnP-3zckMA0NKQ_dXvIqD4JHD-RUBfg3dp00BPzRGXDo25Pca3fH9AMsITZthOINp75yfxvpvmIZj4wNxpHqUu_BhN2OxnWXe79xgn14sMRdYEECzjK/s1600/floyd+warshall.jpg" height="107" width="200" /></a></span></div>
<span style="color: #cc0000;"><br /></span><br />
<span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span><br />
<br />
<span style="color: blue;">void main()<br />{clrscr();<br />int g[10][10],n,i,j,k;<br />cout<<"program for Floyd warshall (all pair shortest path)by: Tarun rawat\n\n";</span><br />
<br />
<a name='more'></a><span style="color: blue;">cout<<"Enter number of vertices n= ";<br />cin>>n;<br />cout<<"Enter n*n adjacency matrix \n";<br />for(i=0;i<n;i++)<br /> {for(j=0;j<n;j++)<br /> { cin>>g[i][j];<br /> }<br /> }<br />for(k=0;k<n;k++)<br /> {for(i=0;i<n;i++)<br /> {<br /> if (g[i][k]>0)<br /> {for(j=0;j<n;j++)<br /> {if(g[k][j]>0 && g[i][j]>(g[i][k]+g[k][j]))<br /> {g[i][j]=g[i][k]+g[k][j];<br /> }<br /> }<br /> }<br /> }<br /> }<br />cout<<"\nOutput : \n";<br />for(i=0;i<n;i++)<br /> {for(j=0;j<n;j++)<br /> { cout<<g[i][j]<<" ";<br /> }<br /> cout<<"\n";<br /> }<br /><br />getch();<br />}</span>Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com3tag:blogger.com,1999:blog-3770499729720157846.post-64036517682566835342014-05-03T03:39:00.001-07:002014-05-03T03:39:57.496-07:00Quick Sort<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIb9QrifUK1KFoD3LOpg-9TrGA9XORhbh5Pq3grx5JQvYld6knnIWQReYyRPbV_FAAP5N38ADPvs1v6IB5VCzFpPJChYWc7IQsqf4xKUFaoXGcl7piKUMOozx6EjcXFWGHkd1nn_gd7y9-/s1600/quick.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIb9QrifUK1KFoD3LOpg-9TrGA9XORhbh5Pq3grx5JQvYld6knnIWQReYyRPbV_FAAP5N38ADPvs1v6IB5VCzFpPJChYWc7IQsqf4xKUFaoXGcl7piKUMOozx6EjcXFWGHkd1nn_gd7y9-/s1600/quick.jpg" height="130" width="200" /></a></div>
<u><b>Source Code:</b></u><br />
<br />
<span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span><br /><span style="color: blue;">void quicksort(int*,int,int);<br />int partion(int*,int,int);<br />void main()<br />{clrscr();<br /> cout<<"Enter ten number for quick sort by-Tarun rawat:\n\n";</span><br />
<a name='more'></a><br /> int a[10];<br /> for(int i=0;i<10;i++)<br /> {cin>>a[i];<br /> }<br /> int p=0,q=9;<br /> quicksort(a,p,q);<br /> cout<<"After applying quick sort :\n";<br /> for(i=0;i<10;i++)<br /> {cout<<a[i]<<" ";<br /> }<br /> getch();<br />}<br /><br />void quicksort(int a[],int p,int q)<br />{ if(p<q)<br /> {int r=partion(a,p,q);<br /> quicksort(a,p,r-1);<br /> quicksort(a,r+1,q);<br /> }<br />}<br /><br />int partion(int a[],int p,int q)<br />{ int x=a[p];<br /> int i=p;int temp;<br /> for(int j=p+1;j<=q;j++)<br /> { if(a[j]<= x)<br /> {i=i+1;<br /> temp=a[i];<br /> a[i]=a[j];<br /> a[j]=temp;<br /> }<br /> }<br /> temp=a[p];<br /> a[p]=a[i];<br /> a[i]=temp;<br /> return i;<br />}<br />Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com0tag:blogger.com,1999:blog-3770499729720157846.post-85474104372640419032014-05-03T03:32:00.001-07:002014-05-03T03:32:19.587-07:00Heap Sort (using random input)<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0CTNrqrhKb-55vi6Z5D3vaGIfjv7-fAXfLu0miu5GpLYCNIwk87tTr6RWWtCjBslcvFrRM2jrqvJrYiuRaT-SOcH_huNMAGqvUmu96wLdwyg0d6I6FWzizpkYpAEJI8nrdjtz3n6sx617/s1600/HEAP+sort.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0CTNrqrhKb-55vi6Z5D3vaGIfjv7-fAXfLu0miu5GpLYCNIwk87tTr6RWWtCjBslcvFrRM2jrqvJrYiuRaT-SOcH_huNMAGqvUmu96wLdwyg0d6I6FWzizpkYpAEJI8nrdjtz3n6sx617/s1600/HEAP+sort.jpg" height="117" width="200" /></a></div>
<u><b>Source Code:</b></u><br />
<br />
<span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h><br />#include<stdlib.h><br />#include<math.h><br />#define MAXSIZE RAND_MAX</span><br />
<a name='more'></a><br />
<br /><span style="color: blue;">void MAX_HEAPIFY(int *A, int i, int n);<br />void BUILD_MAX_HEAP(int *A, int n);<br />void HEAP_SORT(int *A, int n);<br />int RECURSIVE_BINARY_SEARCH(int *A, int s,int e, int key)<br />{<br />int mid=ceil((s+e)/2);<br />if(A[mid]==key)<br />{<br />return mid;<br />}<br />if(s>=e)<br />{<br />return -1;<br />}<br />if(A[mid]>key)<br />{<br />return RECURSIVE_BINARY_SEARCH(A,s,mid-1,key);<br />}<br />else<br />{<br />return RECURSIVE_BINARY_SEARCH(A,mid+1,e,key);<br />}<br />}<br /><br /><br />//function to get a random number between 1 and max<br />int GetRandom(int max)<br />{<br />return rand()%max +1;<br />}<br />//create an input array of size n by assigning random integers<br />//from 1 to n at each location<br />int* createRandomInput(int n)<br />{<br />int *A= new int[n];<br />for(int i=0;i<n;i++){<br />A[i]=GetRandom(n);<br />}<br />return(A);<br />}<br />void MAX_HEAPIFY(int *A,int i,int n)<br />{<br />int l,r,largest=i,x;<br />l=2*(i+1) -1;<br />r=2*(i+1);<br />if((l<n)&& (A[l]>A[i]))<br />largest=l;<br />if(r<n && A[r]>A[largest])<br />largest=r;<br />if(largest!=i)<br />{<br />x=A[i];<br />A[i]=A[largest];<br />A[largest]=x;<br />MAX_HEAPIFY(A,largest,n);<br />}<br />}<br /><br />void BUILD_MAX_HEAP(int *A,int n)<br />{<br />int i;<br />for(i=n/2;i>=0;i--)<br />{<br />MAX_HEAPIFY(A,i,n);<br />}<br />}<br /><br />void HEAP_SORT(int *A,int n)<br />{<br />int i,x;<br />for(i=0;i<=n-1;i++)<br />{<br />x=A[0];<br />A[0]=A[n-i-1];<br />A[n-i-1]=x;<br /><br />MAX_HEAPIFY(A,0,n-i-1);<br />}<br />}<br />void main()<br />{<br />int n,*A;<br />clrscr();<br />cout<<"Program for HEAP SORT (using random input array)by-Tarun rawat\n\n ";<br />//take size of input from user between 1 and maxsize<br />//check for correctness<br />n=0;<br />while(n<=0 || n>MAXSIZE)<br />{<br />cout<<"Please define input size between 1 and "<<MAXSIZE<<":";<br />cin>>n;<br />}<br />//create random array<br />A=createRandomInput(n);<br />//Note-This is for our test for now.<br />//right now<br />//output array to the user<br />for(int i=0;i<n;i++)<br />{<br />cout<<A[i]<<",";<br />}<br />cout<<"\n";<br />BUILD_MAX_HEAP(A,n);<br />HEAP_SORT(A,n);<br />for(i=0;i<n;i++)<br />{<br />cout<<A[i]<<",";<br />}<br />int key;<br />cout<<"\n enter the element to be searched:";<br />cin>>key;<br />int loc=RECURSIVE_BINARY_SEARCH(A,0,n-1,key);<br />cout<<"\nthe element found at:"<< loc;<br />if(loc!=-1)<br />{<br />cout<<"\nelement found is:"<<key;<br />}<br />else<br />{<br />cout<<"\nelement not found ";<br />}<br />getch();<br />}</span>Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com1tag:blogger.com,1999:blog-3770499729720157846.post-70411879613293770032014-05-03T02:30:00.002-07:002014-05-03T02:41:26.434-07:000/1 Knapsack Problem<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw3jCAiniv5wxN6SDKFc4jFn4UOkj9aBEezEhB34AqwyuGbgxHVSaJ0y4ocXf-w5HUXuinfzF3w7ofM5mmt7pWfr4arKpsY7TX1Z4f703qunB1YpW61wTPwTcV8lBbLvvFxPqIX0N76GRC/s1600/Unddddtitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjw3jCAiniv5wxN6SDKFc4jFn4UOkj9aBEezEhB34AqwyuGbgxHVSaJ0y4ocXf-w5HUXuinfzF3w7ofM5mmt7pWfr4arKpsY7TX1Z4f703qunB1YpW61wTPwTcV8lBbLvvFxPqIX0N76GRC/s1600/Unddddtitled.jpg" height="100" width="200" /></a></div>
Given weights and values of n items, put these items in a knapsack of
capacity W to get the maximum total value in the knapsack. <span id="more-18430"></span>
In other words, given two integer arrays val[0..n-1] and wt[0..n-1]
which represent values and weights associated with n items respectively.
Also given an integer W which represents knapsack capacity, find out
the maximum value subset of val[] <br />
<a name='more'></a>such that sum of the weights of this
subset is smaller than or equal to W. You cannot break an item, either
pick the complete item, or don’t pick it (0-1 property).<br />
<br />
<u><b>Source Code: </b></u><br />
<br />
<span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span><br />
<br />
<span style="color: blue;">void knapsack(float*,float*,float,float);<br />void main()<br />{ clrscr();<br /> float value[50],weight[50],max,i,n;<br /> cout<<"Program for 0/1 knapsack by-Tarun Rawat \n\n";<br /> cout<<"Enter the maximum capacity of knapsack: ";<br /> cin>>max;<br /> cout<<"Enter the number of item: ";<br /> cin>>n;<br /> cout<<"Enter the values of item,according to per unit value in descending order:\n";<br /> for( i=0;i<n;i++)<br /> {cin>>value[i];<br /> }<br /> cout<<"Enter the values of weight according to value of item:\n";<br /> for( i=0;i<n;i++)<br /> {cin>>weight[i];<br /> }<br /> cout<<"Elements enter by you is \n";<br /> for( i=0;i<n;i++)<br /> {cout<<"\nvalue "<<value[i]<<" weight "<<weight[i];<br /> }<br /> knapsack(value,weight,max,n);<br />getch();<br />}<br /><br />void knapsack(float value[],float weight[],float max,float n)<br /> { float current=0,i,rem;<br /> float currentval=0;<br /> for(i=0;i<n;i++)<br /> { if((current<=max)&& (weight[i]<=max-current))<br /> { current=current+weight[i];<br /> currentval=currentval+value[i];<br /> }<br /> }<br /> rem=max-current;<br /> cout<<"\n\nmaximum profit is: "<<currentval;<br /> cout<<"\ncurrent weight is: "<<current;<br /> cout<<"\nweight left: "<<rem;<br /> }</span>Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com0tag:blogger.com,1999:blog-3770499729720157846.post-80686793602056177242014-05-03T01:42:00.002-07:002014-05-03T01:44:26.841-07:00Job Scheduling<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3jtqrZK2S00g9HA0nzFL68a4saOBvl3IklU3KOPY3JeWEvKHr2Oi_Jca9adjBwRl39GhwGrPJ9KdpQmZXba-XSG93Q-lHv3JtjzrqNK6hMusmuJH7k1m87k5DWTNxCvH3_bfUrHlkr4xU/s1600/Untdffditled.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3jtqrZK2S00g9HA0nzFL68a4saOBvl3IklU3KOPY3JeWEvKHr2Oi_Jca9adjBwRl39GhwGrPJ9KdpQmZXba-XSG93Q-lHv3JtjzrqNK6hMusmuJH7k1m87k5DWTNxCvH3_bfUrHlkr4xU/s1600/Untdffditled.jpg" height="130" width="200" /></a></div>
<u><b>Source Code:</b></u><br />
<span style="color: #cc0000;"><br /></span>
<span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span><br />
<span style="color: blue;">void job(int*,int*,int,int);<br />void main()<br />{clrscr();<br /> cout<<"Program created by Tarun Rawat Job Scheduling\n\n";</span><br />
<a name='more'></a><span style="color: blue;"><br /> int profit[20],dead[20],n,i,j,maxdead;</span><br />
<br />
cout<<"Enter number of element : ";<br />
cin>>n;<br />
cout<<"Enter profit in descending order: \n";<br />
for(i=0;i<n;i++)<br />
{cin>>profit[i];<br />
}<br />
cout<<"Enter deadline according to profit value typed above : \n";<br />
for(i=0;i<n;i++)<br />
{cin>>dead[i];<br />
}<br />
cout<<"Enter maximum deadline : ";<br />
cin>>maxdead;<br />
job(profit,dead,n,maxdead);<br />
getch();<br />
}<br />
<br />
void job(int profit[],int dead[],int n,int maxdead)<br />
{ int result[20],total=0,x=0;<br />
for(int i=0;i<maxdead;i++)<br />
{result[i]=0;<br />
}<br />
for( i=0;i<n;i++)<br />
{ if(result[dead[i]-1]==0)<br />
{result[dead[i]-1]=profit[i];<br />
total=total+profit[i];<br />
}<br />
else<br />
{ for(int j=dead[i]-1;j>=0;j--)<br />
{if(result[j]==0)<br />
{result[j]=profit[i];<br />
total=total+profit[i];<br />
}<br />
}<br />
}<br />
<br />
}<br />
cout<<"Total profit is " <<total;<br />
cout<<"\nOutput array is : \n";<br />
for(i=0;i<maxdead;i++)<br />
{cout<<"At index "<<i+1<<" "<<result[i]<<"\n"; ///Tarun rawat<br />
}<br />
}<br />
<br />Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com0tag:blogger.com,1999:blog-3770499729720157846.post-26413521470989563442014-05-03T01:21:00.002-07:002014-05-03T01:21:35.040-07:00Fractional Knapsack <div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0u3O1OIQeLhmqAZOOnheImMRfEshFQiEN1VP9Z_PWYU4F5phsha6o9VUAWzrUP6ZOsYGauk_QQDR35VW_IjDM9jdFYQJFBG_-CgWjy1usPIfiGhEn5599FFtcce0Fy5rKjZCm46cLO_4Y/s1600/Untffitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0u3O1OIQeLhmqAZOOnheImMRfEshFQiEN1VP9Z_PWYU4F5phsha6o9VUAWzrUP6ZOsYGauk_QQDR35VW_IjDM9jdFYQJFBG_-CgWjy1usPIfiGhEn5599FFtcce0Fy5rKjZCm46cLO_4Y/s1600/Untffitled.jpg" height="131" width="200" /></a></div>
<span style="font-size: medium;">There are n items in a store. For i =1,2, . . . , n, item i has weight wi > 0 and worth vi > 0. Thief can carry a maximum weight of W pounds in a knapsack. In this version of a problem the items can be broken into smaller piece, so the thief may decide to carry only a fraction xi of object i, where 0 ≤ xi ≤ 1. Item i contributes xiwi to the total weight in the knapsack, and xivi to the value of the load.here
are </span><span style="font-size: large;"> <i>n</i></span><span style="font-size: medium;"> items in a store. </span><br />
<br />
<a name='more'></a><br /><br />
<br />
<u><b>Source Code:-</b></u><br />
<br />
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:RelyOnVML/>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]--><br />
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-IN</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
</style>
<![endif]-->
<br />
<span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span><br /><br /><span style="color: blue;">void knapsack(float*,float*,float,float);<br />void main()<br />{ clrscr();<br /> float value[50],weight[50],max,i,n;<br /> cout<<"Program for Fractional knapsack by-Tarun Rawat \n\n";<br /> cout<<"Enter the maximum capacity of knapsack: ";<br /> cin>>max;<br /> cout<<"Enter the number of item: ";<br /> cin>>n;<br /> cout<<"Enter the values of item,according to per unit value in descending order:\n";<br /> for( i=0;i<n;i++)<br /> {cin>>value[i];<br /> }<br /> cout<<"Enter the values of weight according to value of item:\n";<br /> for( i=0;i<n;i++)<br /> {cin>>weight[i];<br /> }<br /> cout<<"Elements enter by you is \n";<br /> for( i=0;i<n;i++)<br /> {cout<<"\nvalue "<<value[i]<<" weight "<<weight[i];<br /> }<br /> knapsack(value,weight,max,n);<br />getch();<br />}<br /><br />void knapsack(float value[],float weight[],float max,float n)<br /> { float current=0,i=0,rem;<br /> float currentval=0;<br /> while((current<=max)&& (weight[i]<=max-current))<br /> { current=current+weight[i];<br /> currentval=currentval+value[i];<br /> i++;<br /> }<br /> rem=max-current;<br /> if(current<max)<br /> {current =current+rem;<br /> currentval=currentval+((rem * value[i])/weight[i] );<br /> }<br /><br /> cout<<"\n\nmaximum profit is: "<<currentval;<br /> cout<<"\ncurrent weight is: "<<current;<br /> }</span><br />Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com3tag:blogger.com,1999:blog-3770499729720157846.post-29006941150223309432014-03-16T23:13:00.001-07:002014-03-16T23:14:02.278-07:00Calculate nPr & nCr<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNfAsqSc1l-qjsnvJS4zDFkw0V7SBA3wgh8QClYBJxHjWtDKTKEJ4C6MvzpQD2jPzpMNNPshtDMW4Qx_INJhY09MJ-99Q55GuINDLpJ3rooYcUGSlcQ14_fqqwShufkNOZ7MuyVLVTFHiZ/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNfAsqSc1l-qjsnvJS4zDFkw0V7SBA3wgh8QClYBJxHjWtDKTKEJ4C6MvzpQD2jPzpMNNPshtDMW4Qx_INJhY09MJ-99Q55GuINDLpJ3rooYcUGSlcQ14_fqqwShufkNOZ7MuyVLVTFHiZ/s1600/Untitled.jpg" height="104" width="320" /></a></div>
C++ Program to calculate nPr & nCr. This program calculates the value of nCr and nPr. The values of n and r
are input by user. We have used 3 functions : 'npr' for calculating nPr ,
'ncr' for calculating nCr , factorial to calculate factorial. nPr is
calculated by the formula nPr = factorial(n)/factorial(n-r)<br />
<a name='more'></a>, nCr by
factorial(n)/(factorial(r)*factorial(n-r)). The values are calculated by these functions and factorial by 'factorial'. The results are printed using cout.<br />
<br />
<u><b>Source Code:- </b></u><br />
<span style="color: #cc0000;"><br /></span>
<span style="color: blue;"><span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span><br />long fnpr(int, int);<br />long fncr(int, int);<br />long factorial(int);<br />void main()<br />{<br /> int n, r;<br /> long ncr, npr;<br /> clrscr();<br /> cout<<"Calculate nCr & nPr by-Tarun Rawat\n";<br /> cout<<"\nEnter the value of n : ";<br /> cin>>n;<br /> cout<<"Enter the value of r : ";<br /> cin>>r;<br /> ncr=fncr(n,r);<br /> npr=fnpr(n,r);<br /> cout<<"\nValue of "<<n<<"C"<<r<<" = "<<ncr;<br /> cout<<"\nValue of "n<<"P"<<r<<" = "<<npr;<br /> getch();<br />}<br />long fnpr(int n,int r)<br />{<br /> long value;<br /> value=factorial(n)/factorial(n-r);<br /> return value;<br />}<br />long fncr(int n,int r)<br />{<br /> long value;<br /> value=factorial(n)/(factorial(r)*factorial(n-r));<br /> return value;<br />}<br />long factorial(int n)<br />{<br /> if(n==0)<br /> return 1;<br /> else<br /> {<br /> return(n*factorial(n-1));<br /> }<br />}</span></div>
Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com1tag:blogger.com,1999:blog-3770499729720157846.post-35347946946345319462014-03-16T23:08:00.001-07:002014-03-16T23:08:40.743-07:00Calculate Simple interest<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHKS0xF9qiYRXYK48ajxxFoC8GIrFBUU9xdLpQZAkzUrMeUoVWLsvcN-Uw5lR5KJ9G-vx2Dtr7Ka8NZZJLi7VhOmwdIKWIGR-8N8qVnEK4Cd9Bx5j28cLN39bqTT0QrlT2FFahL0z00yag/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHKS0xF9qiYRXYK48ajxxFoC8GIrFBUU9xdLpQZAkzUrMeUoVWLsvcN-Uw5lR5KJ9G-vx2Dtr7Ka8NZZJLi7VhOmwdIKWIGR-8N8qVnEK4Cd9Bx5j28cLN39bqTT0QrlT2FFahL0z00yag/s1600/Untitled.jpg" height="120" width="200" /></a></div>
C++ Program to calculate Simple Interest. This program calculates the simple interest and prints the result on the compiler screen.<br />
Three values i.e principal amount(p), interest rate(r) & time
period(t) are input by the user using 'cin'. All three are taken of
'float' type .<br />The formula for simple interest is : p*r*t/100.The result is shown on compiler screen using 'cout'. <br />
<a name='more'></a><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirxNaQ5Nsvzco1RtnvbMpUHr_m_v88PeFHE7jOaAK4exevumFdI0FWcANpVWkG-GZXrFG-VE3V1X9pioCPumhn4OySoCeX8sc0r5ezSlhATazMf5PBWPZ077_6TN06sQOqv12v1niHDpVr/s1600/Untitcled.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirxNaQ5Nsvzco1RtnvbMpUHr_m_v88PeFHE7jOaAK4exevumFdI0FWcANpVWkG-GZXrFG-VE3V1X9pioCPumhn4OySoCeX8sc0r5ezSlhATazMf5PBWPZ077_6TN06sQOqv12v1niHDpVr/s1600/Untitcled.jpg" height="141" width="400" /></a></div>
<u><b>Source Code:-</b></u><br />
<br />
<span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span><br /><span style="color: blue;">void main()<br />{float p,r,t,si;<br /> clrscr();<br /> cout<<"Program to calculate Simple Intrest by-Tarun Rawat\n";<br /> cout<<"Enter the amount : ";<br /> cin>>p;<br /> cout<<"Enter the rate of intrest in percent : ";<br /> cin>>r;<br /> cout<<"Enter the time in year : ";<br /> cin>>t;<br /> si=p*r*t/100;<br /> cout<<"\nSimple Interest is : "<<si;<br /> getch();<br />}</span></div>
Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com1tag:blogger.com,1999:blog-3770499729720157846.post-16510051672785730132014-03-16T23:02:00.000-07:002014-03-16T23:02:00.439-07:00Sum of G.P<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxobomvhMJ-TFsh72aT8hgGdP0_9VDsqER8W-VCJQaL1HcvRhQomST3F5tuC4XC1J8bVzFDLGnv17tkBn0qItjB8gpatNTghBy8IbUNZjyKZoD9cPNhuRnvqONGIJGRKfMdr0DlvCNQGm-/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxobomvhMJ-TFsh72aT8hgGdP0_9VDsqER8W-VCJQaL1HcvRhQomST3F5tuC4XC1J8bVzFDLGnv17tkBn0qItjB8gpatNTghBy8IbUNZjyKZoD9cPNhuRnvqONGIJGRKfMdr0DlvCNQGm-/s1600/Untitled.jpg" height="120" width="200" /></a></div>
C++ Program to calculate sum of finite G.P. This program calculates the sum of the a finite G.P. and prints the
result on the compiler screen. The first term 'a', number of terms 'n'
and the common ratio 'r' are input by the user. Sum of an G.P. is calculated by the formula : sum=(a*(1-pow(r,n+1)))/(1-r) , n<sup>th</sup> term by : nth=a*pow(r,n-1) . For loop is used to print the whole series
upto n <br />
<a name='more'></a>and the sum is printed on compiler screen <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTGI1rcfy7JmSXOEEkzczjLSiqbsssd7jfk4qks25JQliFvWD3r2ckJDI6q98rm1Qf0E3UVOajVWmS3wU9T0lxSu-RK2WiUDXzyE5NF5GWsFuuE_fv2kxeBF_IRnRPlY7TVhoi-wagBeFO/s1600/Untitsled.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTGI1rcfy7JmSXOEEkzczjLSiqbsssd7jfk4qks25JQliFvWD3r2ckJDI6q98rm1Qf0E3UVOajVWmS3wU9T0lxSu-RK2WiUDXzyE5NF5GWsFuuE_fv2kxeBF_IRnRPlY7TVhoi-wagBeFO/s1600/Untitsled.jpg" height="136" width="400" /></a></div>
<br />
<u><b>Source Code:-</b></u><br />
<br />
<span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h><br />#include<math.h></span><br /><span style="color: blue;">void main()<br />{<br /> float a,r,i,nth;<br /> int n;<br /> float sum=0;<br /> clrscr();<br /> cout<<"Program to calculate sum of G.P. by-Tarun Rawat\n";<br /> cout<<"Enter the first number of series : ";<br /> cin>>a;<br /> cout<<"Enter the number of terms in series : ";<br /> cin>>n;<br /> cout<<"Enter the common ratio of series : ";<br /> cin>>r;<br /> sum=(a*(1-pow(r,n+1)))/(1-r);<br /> nth=a*pow(r,n-1);<br /> cout<<"n'th term of G.P. : "<<nth;<br /> cout<<"\nSum of the G.P. : "<<sum;<br /> getch();<br />}</span></div>
Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com0tag:blogger.com,1999:blog-3770499729720157846.post-80717148460764918382014-03-16T22:42:00.000-07:002014-03-16T22:42:31.095-07:00All Number Patterns<div dir="ltr" style="text-align: left;" trbidi="on">
Below is a complete list of all the Number patterns.Outputs of all the codes have been put below the respective codes. This allows the user to view how the code works.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPCfhZ36-sij5fYu0FR6H3tL11Nqu2uprmrh9uumMOcILhdGd90EozJAgjJQ6vam-rPzKaUJQXC3e5TbRkRhBO6gY3MytF_MziBYqdIA8UwfFa3QeqIsuXoqQOJCKsi2nzADhamA_NDDuT/s1600/6.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPCfhZ36-sij5fYu0FR6H3tL11Nqu2uprmrh9uumMOcILhdGd90EozJAgjJQ6vam-rPzKaUJQXC3e5TbRkRhBO6gY3MytF_MziBYqdIA8UwfFa3QeqIsuXoqQOJCKsi2nzADhamA_NDDuT/s1600/6.jpg" /></a></div>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkGP-XT7lLbkDqQLzzC4gU4fL9zMHUzT1c3fwfz-vVw-bQrmFHhBcf3yThanqZbH_Bdi0nyxhd_BEyEz4LEOh0d6yyttKfJWthPWNmbEdzIu8rLzF4utMM-HRrdfhA7EXVPiMxvWHKlDU/s1600/1.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkGP-XT7lLbkDqQLzzC4gU4fL9zMHUzT1c3fwfz-vVw-bQrmFHhBcf3yThanqZbH_Bdi0nyxhd_BEyEz4LEOh0d6yyttKfJWthPWNmbEdzIu8rLzF4utMM-HRrdfhA7EXVPiMxvWHKlDU/s1600/1.jpg" /></a> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt9p5Min5RIXeanRbtHunpgwhRdufV8V5OtKMWVr_zka0LFsdBsgNPOQ5pfdmilhJ2kzzgyGt2YG7bAUotjaW2Ytu3k_TjgVAy8jdxwX7IPsnPY6Qx5WYfacjJcKVo8PJkzF3gLmdmmcph/s1600/2.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt9p5Min5RIXeanRbtHunpgwhRdufV8V5OtKMWVr_zka0LFsdBsgNPOQ5pfdmilhJ2kzzgyGt2YG7bAUotjaW2Ytu3k_TjgVAy8jdxwX7IPsnPY6Qx5WYfacjJcKVo8PJkzF3gLmdmmcph/s1600/2.jpg" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR3mOAC1Sn4Obw9zBrYKEMfKjgleiCkKRQdyWkepD2r4KnPHe-3RTeLjbIYVOzS3Ozq_yP_e1m_MNW_8DxFOsMomKhW6Ff3nvfttKAtd2qeOd0iFyR6l9FbVLAeF4ppwj49nv29fdaLEkS/s1600/3.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR3mOAC1Sn4Obw9zBrYKEMfKjgleiCkKRQdyWkepD2r4KnPHe-3RTeLjbIYVOzS3Ozq_yP_e1m_MNW_8DxFOsMomKhW6Ff3nvfttKAtd2qeOd0iFyR6l9FbVLAeF4ppwj49nv29fdaLEkS/s1600/3.jpg" /></a><br />
<a name='more'></a><br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidX3KD_d-shpxt67wJm6tKhi3A-FMMbnUZ636bHOODsDO3hVsIiXvTztfIHIMsLvuJVjhAd3H9NcKN5XXX4dL6Ymx3Ss_JxNUmEYIzptYr7CEOQON6W8UVBy94UogfcTZMSpGTnF-lFujO/s1600/4.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidX3KD_d-shpxt67wJm6tKhi3A-FMMbnUZ636bHOODsDO3hVsIiXvTztfIHIMsLvuJVjhAd3H9NcKN5XXX4dL6Ymx3Ss_JxNUmEYIzptYr7CEOQON6W8UVBy94UogfcTZMSpGTnF-lFujO/s1600/4.jpg" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyXfXmGltULlGc2xX2oAohBCwj0KpMpW54x8nY5BTjHRWEo8Zqj1Xa5Mp9a7VJFJnq1qasbUqNsmska2-WsuDZfk-5MJ2IyaTWdLH2hwHQXTzwAHoFhRRYkpqeVtc2Ze1Rx8R9WqoVgajS/s1600/5.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyXfXmGltULlGc2xX2oAohBCwj0KpMpW54x8nY5BTjHRWEo8Zqj1Xa5Mp9a7VJFJnq1qasbUqNsmska2-WsuDZfk-5MJ2IyaTWdLH2hwHQXTzwAHoFhRRYkpqeVtc2Ze1Rx8R9WqoVgajS/s1600/5.jpg" /></a><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOkGP-XT7lLbkDqQLzzC4gU4fL9zMHUzT1c3fwfz-vVw-bQrmFHhBcf3yThanqZbH_Bdi0nyxhd_BEyEz4LEOh0d6yyttKfJWthPWNmbEdzIu8rLzF4utMM-HRrdfhA7EXVPiMxvWHKlDU/s1600/1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt9p5Min5RIXeanRbtHunpgwhRdufV8V5OtKMWVr_zka0LFsdBsgNPOQ5pfdmilhJ2kzzgyGt2YG7bAUotjaW2Ytu3k_TjgVAy8jdxwX7IPsnPY6Qx5WYfacjJcKVo8PJkzF3gLmdmmcph/s1600/2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<pre id="a"><span style="color: #cc0000;">1
1 2
1 2 3
1 2 3 4
1 2 3 4 5</span></pre>
<pre id="a"><span style="color: #cc0000;"> </span></pre>
<pre id="a"><span style="color: #cc0000;"><span style="color: orange;"><b style="font-size: 17px; padding-left: 0px;">Code:</b> </span>
<span style="color: blue;">#include<iostream.h>
#include<conio.h>
void main()
{
int i,j,row;
clrscr();
cout<<"Enter the number of rows you want:\n";
cin>>row;
for(i=1;i<=row;i++)
{
for(j=1;j<=i;j++)
{
cout<<j;
}
cout<<"\n";
}
getch();
} </span></span></pre>
<pre id="a"><span style="color: #cc0000;"> </span></pre>
<pre id="a"><span style="color: #cc0000;"> </span></pre>
<pre id="a"><span style="color: #cc0000;"> 1
2 3
4 5 6
7 8 9 10
11 12 13 14 15 </span></pre>
<pre id="a"><span style="color: #cc0000;">
<span style="color: orange;"><b style="font-size: 17px; padding-left: 0px;">Code:</b> </span>
<span style="color: blue;"></span></span><span style="color: #cc0000;"><span style="color: blue;"><span style="color: #cc0000;"><span style="color: blue;">#include<iostream.h></span></span>
#include<conio.h>
void main()
{
int i,j,k,row;
clrscr();
k=1;
cout<<"Enter the no. of rows you want:\n";
cin>>row;
for(i=1;i<=row;i++)
{
for(j=row;j>=1;j--)
{
if(j>i)
cout<<" ";
else
cout<<k++;
}
cout<<"\n";
}
getch();
} </span></span></pre>
<pre id="a"><span style="color: #cc0000;"> </span></pre>
<pre id="a"><span style="color: #cc0000;"> </span></pre>
<pre id="a"><span style="color: #cc0000;"> </span></pre>
<pre id="a"><span style="color: #cc0000;">1
2 2
3 3 3
4 4 4 4
5 5 5 5 5</span></pre>
<pre id="a"><span style="color: #cc0000;"><span style="color: orange;"><b style="font-size: 17px; padding-left: 0px;">Code:</b> </span>
<span style="color: blue;"></span></span><span style="color: #cc0000;"><span style="color: blue;"><span style="color: #cc0000;"><span style="color: blue;">#include<iostream.h></span></span>
#include<conio.h>
void main()
{
int i,j;
clrscr();
cout<<"Enter the number of rows you want:\n";
cin>>row;
for(i=1;i<=row;i++)
{
for(j=1;j<=i;j++)
{
cout<<i;
}
cout<<"\n";
}
getch();
} </span></span></pre>
<pre id="a"><span style="color: #cc0000;"><span style="color: blue;"> </span></span></pre>
<pre id="a"><span style="color: #cc0000;"> </span></pre>
<pre id="a"><span style="color: #cc0000;">1
2 6
3 7 10
4 8 11 13
5 9 12 14 15</span></pre>
<pre id="a"><span style="color: #cc0000;"> </span></pre>
<pre id="a"><span style="color: #cc0000;"><span style="color: orange;"><b style="font-size: 17px; padding-left: 0px;">Code:</b> </span>
<span style="color: blue;"></span></span><span style="color: #cc0000;"><span style="color: blue;"><span style="color: #cc0000;"><span style="color: blue;">#include<iostream.h></span></span>
#include<conio.h>
void main()
{
int i,j,k,row;
clrscr();
cout<<"Enter the number of rows you want:\n";
cin>>row;
for(i=1;i<=row;i++)
{
k = i;
for(j=1;j<=i;j++)
{
cout<<k;
k += row-j;
}
cout<<"\n";
}
getch();
} </span></span></pre>
<pre id="a"><span style="color: #cc0000;"><span style="color: blue;"> </span></span></pre>
<pre id="a"><span style="color: #cc0000;"> </span></pre>
<pre id="a"><span style="color: #cc0000;"> 1
2 3
4 5 6
7 8 910
1112131415</span></pre>
<pre id="a"><span style="color: #cc0000;"> </span></pre>
<pre id="a"><span style="color: #cc0000;"> </span></pre>
<pre id="a"><span style="color: #cc0000;"><span style="color: orange;"><b style="font-size: 17px; padding-left: 0px;">Code:</b>
</span><span style="color: blue;"></span></span><span style="color: #cc0000;"><span style="color: blue;"><span style="color: #cc0000;"><span style="color: blue;">#include<iostream.h></span></span>
#include<conio.h>
void main()
{
int i,j,k,row;
clrscr();
k=1;
cout<<"Enter the no. of rows you want:\n";
cin>>row;
for(i=1;i<=row;i++)
{
for(j=row;j>=1;j--)
{
if(j>i)
cout<<" ";
else
cout<<k++;
}
cout<<"\n";
}
getch();
} </span></span></pre>
<pre id="a"><span style="color: #cc0000;"><span style="color: blue;"> </span></span></pre>
<pre id="a"><span style="color: #cc0000;"> </span></pre>
<pre id="a"><span style="color: #cc0000;">1
0 1
0 0 1
0 0 0 1
0 0 0 0 1</span></pre>
<pre id="a"><span style="color: #cc0000;"> </span></pre>
<pre id="a"><span style="color: #cc0000;"><span style="color: orange;"><b style="font-size: 17px; padding-left: 0px;">Code:</b></span>
<span style="color: blue;"></span></span><span style="color: #cc0000;"><span style="color: blue;"><span style="color: #cc0000;"><span style="color: blue;">#include<iostream.h></span></span>
#include<conio.h>
void main()
{
int i,j,row;
clrscr();
cout<<"Enter the number of rows you want:\n";
cin>>row;
cout<<"\n";
for(i=1;i<=row;i++)
{
for(j=1;j<=i;j++)
{
cout<<j/i;
}
cout<<"\n";
}
getch();
}</span>
</span></pre>
</div>
Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com0tag:blogger.com,1999:blog-3770499729720157846.post-58054395183678797542014-03-16T22:10:00.002-07:002014-03-17T01:10:25.691-07:00All Asterisk Patterns<div dir="ltr" style="text-align: left;" trbidi="on">
Below is a complete list of all the Asterisk patterns. All these codes
have been complied in Turbo C++ Compiler. Outputs of all the codes have been put below the respective codes.<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGyOpplumyCjv-STMzOSFS7Q-iPnR5ithnkWFXTqYGjFkd9slVcfgSYHc1sLug0TENjzePN6Dmd7jKPohXtazKgOW0rokJzH_OsH23_pbReqvCjCOWh9188OEnI7lhfaYpvbHqoay5S9Ns/s1600/9.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"></a> <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQP3pumJLWhirrEY6kXxY3m675K01ttBFeBC0KxHx4apZtjQ9iJh9FvGqPZZXKCta-SFtZ3aroBlayNncf9QgiRLxE-DCrXVzXHlcwRspWJ6EFXMTaNSsIRuDyMvs-dAMWdwG20EthOKzc/s1600/1.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQP3pumJLWhirrEY6kXxY3m675K01ttBFeBC0KxHx4apZtjQ9iJh9FvGqPZZXKCta-SFtZ3aroBlayNncf9QgiRLxE-DCrXVzXHlcwRspWJ6EFXMTaNSsIRuDyMvs-dAMWdwG20EthOKzc/s1600/1.jpg" /></a></div>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjy6nFAcObMPNi_1CuYQAGA9c477MKDnPGFbPZk3uAJTTXKTMTmDM6YfqkTD_yZ9qiGem66_vI0ObIb5uOH8jrQG3r_WSbahDijJ96ghK2vhsv2qTLIqr5pArHE0D5OOnfJJOZ_ZSYnaE_A/s1600/2.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjy6nFAcObMPNi_1CuYQAGA9c477MKDnPGFbPZk3uAJTTXKTMTmDM6YfqkTD_yZ9qiGem66_vI0ObIb5uOH8jrQG3r_WSbahDijJ96ghK2vhsv2qTLIqr5pArHE0D5OOnfJJOZ_ZSYnaE_A/s1600/2.jpg" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhU_CsfYLoKoov8gFMyr-xzbS0oBRiu3lCM3el_TQVf2gk2s7UHs-MbPCkiQczlO7mO7KPzRYC91ict_Mz9ap42EVAo0VEBB-dXXjZ5UlqfbAcD9bw1L4X4hSu1ZUB3H7vzrHfzxVLnn6A-/s1600/3.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhU_CsfYLoKoov8gFMyr-xzbS0oBRiu3lCM3el_TQVf2gk2s7UHs-MbPCkiQczlO7mO7KPzRYC91ict_Mz9ap42EVAo0VEBB-dXXjZ5UlqfbAcD9bw1L4X4hSu1ZUB3H7vzrHfzxVLnn6A-/s1600/3.jpg" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuRLEym0jgQtBqq2cgY4uvlRJ049wE48Mo4IlIvN7IkN9MI9KaQ9VvBmqJc2FB49m4Ju8TVENauciadlEdUWOPuzwZ9_8ifglksMs30KyL3okqKehqanM-ch10aqs1aJUzM_f6f5o9w-Bl/s1600/4.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuRLEym0jgQtBqq2cgY4uvlRJ049wE48Mo4IlIvN7IkN9MI9KaQ9VvBmqJc2FB49m4Ju8TVENauciadlEdUWOPuzwZ9_8ifglksMs30KyL3okqKehqanM-ch10aqs1aJUzM_f6f5o9w-Bl/s1600/4.jpg" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7KYoRzQAaIgbDPZNwgDEp_kpFUYp3A_5VAAaifq7u3Agum-qMpBwuTatvy5OaXUAORTTFbrffWFsZKgg9dwGxNHADLcYve1YhClBkFSnbKwLAi4X8aXWD8TgsJ19GlXt4KvoKW9Q2eX1s/s1600/5.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7KYoRzQAaIgbDPZNwgDEp_kpFUYp3A_5VAAaifq7u3Agum-qMpBwuTatvy5OaXUAORTTFbrffWFsZKgg9dwGxNHADLcYve1YhClBkFSnbKwLAi4X8aXWD8TgsJ19GlXt4KvoKW9Q2eX1s/s1600/5.jpg" /></a><br />
<a name='more'></a><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuUEl8Vbs2XR_uxpNw6FN1tCXDLpoRXWKA96W2jQHXvXYKPVqGgcN5eWZWvNjYIFWlParUjyxRXARW423MflJH-i4jthPS-MjGXTeZBmPJSERR9kKa2Wc8GS2ShgNwILAWC0N_GY1dLnDc/s1600/6.jpg" /> <img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZm2sIJkIt0mB9_xrLjDClKtZaB6_q8ErfgE47mrWgYA37OAKc8QwrGjLMIw5cJUDunR3sbTYOjPWMNvnfTiE28eqjkufMTSaGx1YBBJLry301ggugxFqb0ltLMP_cVxArjTw543bvijTr/s1600/7.jpg" /><span style="color: white;"> </span> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsc0IVSpUCaS-OAXE4IEQnKzxS7N3LcyavHRFq4inxfXrR_ArY4NlHGatEi0g2r3cSe1GnH6JNZ7Nun4jyprYd1FL76mk-a57iBozMHcpV2ZcyCUp7xuCkcXSynyoo6LLYqbIwSs6hwA_2/s1600/8.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsc0IVSpUCaS-OAXE4IEQnKzxS7N3LcyavHRFq4inxfXrR_ArY4NlHGatEi0g2r3cSe1GnH6JNZ7Nun4jyprYd1FL76mk-a57iBozMHcpV2ZcyCUp7xuCkcXSynyoo6LLYqbIwSs6hwA_2/s1600/8.jpg" /></a> <img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGyOpplumyCjv-STMzOSFS7Q-iPnR5ithnkWFXTqYGjFkd9slVcfgSYHc1sLug0TENjzePN6Dmd7jKPohXtazKgOW0rokJzH_OsH23_pbReqvCjCOWh9188OEnI7lhfaYpvbHqoay5S9Ns/s1600/9.jpg" /><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhU_CsfYLoKoov8gFMyr-xzbS0oBRiu3lCM3el_TQVf2gk2s7UHs-MbPCkiQczlO7mO7KPzRYC91ict_Mz9ap42EVAo0VEBB-dXXjZ5UlqfbAcD9bw1L4X4hSu1ZUB3H7vzrHfzxVLnn6A-/s1600/3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<pre id="a"><span style="color: red;">*
**
***
****
*****</span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><b style="color: #0a4f51; font-size: 17px; padding-left: 0px;"> Code:</b> </span></pre>
<pre id="a"><span style="color: blue;"><span style="color: #cc0000;"><span style="color: blue;">#include<iostream.h></span></span>
#include<conio.h></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: blue;"> </span></pre>
<pre id="a" style="color: #510a23;"><span style="color: blue;">void main()
{int row,i,j;
clrscr();
cout<<"Enter the number of rows you want: \n";
cout<<row;
for(i=1;i<=row;i++)
{
for(j=1;j<=i;j++)
{
cout<<"* ";
}
cout<<"\n";
}
getch();
} </span></pre>
<pre id="a" style="color: #510a23;"></pre>
<pre id="a" style="color: #510a23;"></pre>
<pre id="a" style="color: #510a23;"></pre>
<pre id="a" style="color: #510a23;"> <span style="color: #cc0000;"> *
**
***
****
*****</span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"> <b style="color: #0a4f51; font-size: 17px; padding-left: 0px;">Code:</b>
</span><span style="color: #cc0000;"><span style="color: blue;"><span style="color: #cc0000;"><span style="color: blue;">#include<iostream.h></span></span>
#include<conio.h>
void main()
{
int i, j, k, row;
clrscr();
cout<<"Enter the number of rows you want:\n";
cin>>row;
for(i=row;i>=1;i--)
{
for(j=1;j<i;j++)
{
cout<<" ";
}
for(k=row;k>=i;k--)
{
cout<<"*";
}
cout<<"\n";
}
getch();
}</span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: blue;"> </span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: blue;"> </span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;">*****
****
***
**
* </span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> <b style="color: #0a4f51; font-size: 17px; padding-left: 0px;">Code:</b>
</span></span><span style="color: #cc0000;"><span style="color: red;"><span style="color: blue;"><span style="color: #cc0000;"><span style="color: blue;">#include<iostream.h></span></span>
#include<conio.h>
void main()
{
int i, j, k, row;
clrscr();
cout<<"Enter the number of rows you want:\n";
cin>>row;
for(i=row;i>=1;i--)
{
for(j=row;j>i;j--)
{
cout<<" ";
}
for(k=1;k<=i;k++)
{
cout<<"*";
}
cout<<"\n";
}
getch();
} </span></span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> </span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> </span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> *
***
*****
*******
********* </span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> <b style="color: #0a4f51; font-size: 17px; padding-left: 0px;">Code:</b>
</span></span><span style="color: #cc0000;"><span style="color: red;"><span style="color: blue;"><span style="color: #cc0000;"><span style="color: blue;">#include<iostream.h></span></span>
#include<conio.h>
void main()
{
int i,j,k,row;
clrscr();
cout<<"Enter the number of rows you want:\n";
cin>>row;
for(i=1;i<=row;i++)
{
for(j=i;j<row;j++)
{
cout<<" ";
}
for(k=1;k<(i*2);k++)
{
cout<<"*";
}
cout<<"\n";
}
getch();
} </span></span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> </span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> </span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;">*********
*******
*****
***
*</span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> <b style="color: #0a4f51; font-size: 17px; padding-left: 0px;">Code:</b>
</span></span><span style="color: #cc0000;"><span style="color: red;"><span style="color: blue;"><span style="color: #cc0000;"><span style="color: blue;">#include<iostream.h></span></span>
#include<conio.h>
void main()
{
int i,j,k,row;
clrscr();
cout<<"Enter the number of rows you want:\n";
cin>>row;
for(i=row;i>=1;i--)
{
for(j=row;j>i;j--)
{
cout<<" ";
}
for(k=1;k<(i*2);k++)
{
cout<<"*";
}
cout<<"\n";
}
getch();
} </span></span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> </span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> </span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;">**********
**** ****
*** ***
** **
* *</span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> <b style="color: #0a4f51; font-size: 17px; padding-left: 0px;">Code:</b>
</span></span><span style="color: #cc0000;"><span style="color: red;"><span style="color: blue;"><span style="color: #cc0000;"><span style="color: blue;">#include<iostream.h></span></span>
#include<conio.h>
void main()
{
int row,i,j;
clrscr();
cout<<"Enter the number of rows you want: \n";
cin>>row;
for(i=row;i>=1;i--)
{
for(j=1;j<=i;j++)
{
cout<<"*";
}
for(j=row;j>=1;j--)
{
if(j<=i)
{
cout<<"*";
}
else
{
cout<<" ";
}
}
cout<<"\n";
}
getch();
} </span></span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> </span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> </span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;">* *
** **
*** ***
**** ****
**********</span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> <b style="color: #0a4f51; font-size: 17px; padding-left: 0px;">Code:</b>
</span></span><span style="color: #cc0000;"><span style="color: red;"><span style="color: blue;"><span style="color: #cc0000;"><span style="color: blue;">#include<iostream.h></span></span>
#include<conio.h>
void main()
{
int i,j,k,row;
clrscr();
cout<<"Enter the number of rows you want:\n";
cin>>row;
cout<<"\n";
for(i=1;i<=row;i++)
{
for(j=1;j<=row;j++)
{
if(j<=i)
{
cout<<"*";
}
else
{
cout<<" ";
}
}
for(j=row;j>=1;j--)
{
if(j<=i)
{
cout<<"*";
}
else
{
cout<<" ";
}
}
cout<<"\n";
}
getch();
}</span></span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> </span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> </span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: #cc0000;"><span style="color: red;"> *
***
*****
*******
*********
*******
*****
***
* </span>
</span></pre>
<pre id="a" style="color: #510a23;"><b style="color: #0a4f51; font-size: 17px; padding-left: 0px;">Code:</b>
<span style="color: blue;"><span style="color: #cc0000;"><span style="color: blue;">#include<iostream.h></span></span></span></pre>
<pre id="a" style="color: #510a23;"><span style="color: blue;"><span style="color: #cc0000;"><span style="color: blue;"></span></span>#include<conio.h>
void main()
{
int i,j,k;
clrscr();
for(i=1;i<=5;i++)
{
for(j=i;j<5;j++)
{
cout<<" ";
}
for(k=1;k<(i*2);k++)
{
cout<<"*";
}
cout<<"\n";
}
for(i=4;i>=1;i--)
{
for(j=5;j>i;j--)
{
cout<<" ";
}
for(k=1;k<(i*2);k++)
{
cout<<"*";
}
cout<<"\n";
}
getch();
} </span></pre>
<pre id="a" style="color: #510a23;"> </pre>
<pre id="a" style="color: #510a23;"> </pre>
<pre id="a" style="color: #510a23;"> </pre>
<pre id="a"><span style="color: red;">**********
**** ****
*** ***
** **
* *
** **
*** ***
**** ****
**********</span></pre>
<pre id="a" style="color: #510a23;"> <b style="color: #0a4f51; font-size: 17px; padding-left: 0px;">Code:</b>
<span style="color: blue;"><span style="color: blue;"><span style="color: #cc0000;"><span style="color: blue;">#include<iostream.h></span></span></span>
#include<conio.h>
void main()
{
int i,j,k;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=6-i;j++)
{
cout<<"*";
}
for(k=1;k<i;k++)
{
cout<<" ";
}
for(j=1;j<=6-i;j++)
{
cout<<"*";
}
cout<<"\n";
}
for(i=2;i<=5;i++)
{
for(j=1;j<=i;j++)
cout<<"*";
for(k=1;k<=5-i;k++)
{
cout<<" ";
}
for(j=1;j<=i;j++)
{
cout<<"*";
}
cout<<"\n";
}
getch();
}
</span></pre>
<pre id="a" style="color: #510a23;"></pre>
</div>
Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com4tag:blogger.com,1999:blog-3770499729720157846.post-1842491244255629732014-03-16T11:40:00.001-07:002014-03-16T11:40:22.911-07:00Calculate Sum of an A.P.<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2blhuu1hdNO_wnLfSokqTT98JKigqRV-N-UpH6SG2pqGmUXldxH-8QAcSTv6zbkUeoZ6MYmN4pa2ofOb-BD-ki5LAvghTuRYfBWUF354trQMBiMNmcZK7GN21bwMIVJRxvWApcsHe4aKt/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2blhuu1hdNO_wnLfSokqTT98JKigqRV-N-UpH6SG2pqGmUXldxH-8QAcSTv6zbkUeoZ6MYmN4pa2ofOb-BD-ki5LAvghTuRYfBWUF354trQMBiMNmcZK7GN21bwMIVJRxvWApcsHe4aKt/s1600/Untitled.jpg" height="120" width="200" /></a></div>
C++ Program to Calculate sum Of An A.P. series. This program calculates the sum of the an A.P. and prints the result on
the compiler screen. The first term 'a', number of terms 'n' and the
common difference 'd' are input by the user. Sum of an A.P. is<br />
calculated by the formula : sum=(n*(2*a+(n-1)*d))/2 , n<sup>th</sup>
term by : nth=a+(n-1)*d . For loop is used to print the whole series
upto n and the sum is printed on compiler screen <br />
<a name='more'></a><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil396DvffWQw7eh6Ng7nEZ7ahx_QojxGF6l5dMxkuFCfvCrpiAQA02gTRAVGWlM5ryeVYjdjCEX-UwgYSj1Yslgjvp_G4dl14bQvQjOjKq4NIVjKES_7mR_BWuIVUN-TX-wweLiyBjmp1X/s1600/Untitlded.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil396DvffWQw7eh6Ng7nEZ7ahx_QojxGF6l5dMxkuFCfvCrpiAQA02gTRAVGWlM5ryeVYjdjCEX-UwgYSj1Yslgjvp_G4dl14bQvQjOjKq4NIVjKES_7mR_BWuIVUN-TX-wweLiyBjmp1X/s1600/Untitlded.jpg" height="152" width="400" /></a></div>
<span id="goog_93730574"></span><span id="goog_93730575"></span><br />
<u><b>Source Code:-</b></u><br />
<br />
<span style="color: blue;"><span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h><br />#include<math.h></span><br />void main()<br />{<br /> int a,d,n,i,nth;<br /> int sum=0;<br /> clrscr();<br /> cout<<"Program to Calculate sum of A.P series by-Tarun Rawat\n";<br /> cout<<"\nEnter the first number of the series : ";<br /> cin>>a;<br /> cout<<"\nEnter the number of terms in series : ";<br /> cin>>n;<br /> cout<<"\nEnter the common difference of series : ";<br /> cin>>d;<br /> sum=(n*(2*a+(n-1)*d))/2;<br /> nth=a+(n-1)*d;<br /> cout<<"\nSum of the A.P. is : ";<br /> for(i=a;i<=nth;i=i+d)<br /> {<br /> if(i!=nth)<br /> {<br /> cout<<i<<" + ";<br /> }<br /> else<br /> {<br /> cout<<i<<" = "<<sum;<br /> }<br /> }<br /> getch();<br />}</span></div>
Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com0tag:blogger.com,1999:blog-3770499729720157846.post-44553769023342557472014-03-16T11:35:00.002-07:002014-03-16T11:35:52.796-07:00Calculate sum 1 + 2 + 3 +. . . .+n<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAOOV39A67XOPuDR2xrd4sjWhkkB4RIxmT8PqHiX2g6-zSj4ZA5LaOMgFrgRNJQmD-qZmoKRjWfvZeQe-0azESWc-hPMp7OzTuLAwJ59ANhPmCQMVXLXCmduWCjmf4CZw1fosJzv9sEx7E/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAOOV39A67XOPuDR2xrd4sjWhkkB4RIxmT8PqHiX2g6-zSj4ZA5LaOMgFrgRNJQmD-qZmoKRjWfvZeQe-0azESWc-hPMp7OzTuLAwJ59ANhPmCQMVXLXCmduWCjmf4CZw1fosJzv9sEx7E/s1600/Untitled.jpg" height="120" width="200" /></a></div>
C++ Program to calculate the sum of a series up to N terms.This program calculates the sum of the series 1 + 2 + 3 +. . . . . . . .
.+n and prints the result on the compiler screen. The last number n is
input by the user. Sum of this series is calculated by the formula :
sum=(n*(n+1))/2. For loop is used to print the whole series upto n and
the sum is printed on compiler screen.<br />
<a name='more'></a> <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj3XfVdxiOiOxfUwjTaeo6TJ4xEQHJzqojw3jy7OG1y1_EHyELwWsepObMgc85o4irHtxGB3k279Z-23Te8dVLH0Fp_A7aYCw-fJpnLBEF7hxA42UN05efqJxn0JO9f_WjJdzwRoSeD6IH/s1600/Untitsled.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjj3XfVdxiOiOxfUwjTaeo6TJ4xEQHJzqojw3jy7OG1y1_EHyELwWsepObMgc85o4irHtxGB3k279Z-23Te8dVLH0Fp_A7aYCw-fJpnLBEF7hxA42UN05efqJxn0JO9f_WjJdzwRoSeD6IH/s1600/Untitsled.jpg" height="136" width="400" /></a></div>
<u><b>Source Code:-</b></u><br />
<br />
<span style="color: blue;"><span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span><br />void main()<br />{<br /> int n,i;<br /> int sum=0;<br /> clrscr();<br /> cout<<"Program to calculatesum 1+2+3+...n by-Tarun Rawat\n";<br /> cout<<"\nEnter the value of n : ";<br /> cin>>n;<br /> sum=(n*(n+1))/2;<br /> cout<<"\nSum of the series: ";<br /> for(i=1;i<=n;i++)<br /> {<br /> if (i!=n)<br /> {<br /> cout<<i<<" + ";<br /> }<br /> else<br /> {<br /> cout<<i<<" = "<<sum;<br /> }<br /> }<br /> getch();<br />}</span></div>
Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com0tag:blogger.com,1999:blog-3770499729720157846.post-41315929644265728192014-03-16T11:32:00.000-07:002014-03-17T01:14:26.803-07:00Count Number of Vowels<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3FhVrOgiaDX-ZZDbgJ9cXcrNa2dAIIpii-1yupjjZTRVNflbhjYd1bDug2jItQuIZ7URkjzm76-l2La2RSvvKPscijTfux4P3BH2rQwlT6PL6ZryqbmabVaaYUgMuJQi-zoJZF2HAbEca/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3FhVrOgiaDX-ZZDbgJ9cXcrNa2dAIIpii-1yupjjZTRVNflbhjYd1bDug2jItQuIZ7URkjzm76-l2La2RSvvKPscijTfux4P3BH2rQwlT6PL6ZryqbmabVaaYUgMuJQi-zoJZF2HAbEca/s1600/Untitled.jpg" height="120" width="200" /></a></div>
C++ Program To count the number of Vowels in given string. This program calculates the number of vowels in a string using for loop.
The string is input by the user using gets(). Using gets() allows the
compiler to input the spaces of string also. We have taken a
variable count whose value increases by 1 when a vowel in encountered
during the scan. So value of count keeps on increasing<br />
<a name='more'></a> until the string
scan is completed and vowels are encountered.The length of string is
calculated and the result is printed on compiler screen.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbgSY6AlFe5UvfYoqTcAvGh-AoZYn2hQUQfSgoCdqXd-0O7ZtGJY_IbF-R_8I2vWi8TTO0-ga3TCbpwRC93QBrQotbXC83RFtp3bAYoWHG76Tf-P9lFy2zU1wcNV4Bs0zlY9dM4sanvhBS/s1600/Untitledd.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbgSY6AlFe5UvfYoqTcAvGh-AoZYn2hQUQfSgoCdqXd-0O7ZtGJY_IbF-R_8I2vWi8TTO0-ga3TCbpwRC93QBrQotbXC83RFtp3bAYoWHG76Tf-P9lFy2zU1wcNV4Bs0zlY9dM4sanvhBS/s1600/Untitledd.jpg" height="100" width="400" /></a></div>
<u><b>Source Code:-</b></u><br />
<span style="color: #cc0000;"><br /></span>
<span style="color: blue;"><span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span><br />void main()<br />{<br /> char ch[20];<br /> int i,count=0;<br /> clrscr();<br /> cout<<"Prgram to count number of vowels by-Tarun Rawat\n";<br /> cout<<"Enter the string\n";<br /> gets(ch);<br /> for(i=0;ch[i]!='\0';i++)<br /> {<br /> if(ch[i]=='a' || ch[i]=='e' || ch[i]=='i' || ch[i]=='o' ||<br /> ch[i]=='u')<br /> {<br /> count++;<br /> }<br /> }<br /> cout<<"Vowels = "<<count;<br /> getch();<br />}</span></div>
Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com0tag:blogger.com,1999:blog-3770499729720157846.post-7671754310708820022014-03-16T11:27:00.003-07:002014-03-16T11:27:51.400-07:00Inverse of a Matrix<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI5n1VaENivD0qBvc2zRByx0ItYOHhGy9MBjvpsWazkdUF2-AnApeX_2oE2Gi8ElSZoJnKFLoxmsCMffUlvXDg8b6VhCvIRqo2mEHPe7EW9shysv08nnKwxfezLtrYJydZnFje3V1CkdLe/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhI5n1VaENivD0qBvc2zRByx0ItYOHhGy9MBjvpsWazkdUF2-AnApeX_2oE2Gi8ElSZoJnKFLoxmsCMffUlvXDg8b6VhCvIRqo2mEHPe7EW9shysv08nnKwxfezLtrYJydZnFje3V1CkdLe/s1600/Untitled.jpg" height="95" width="200" /></a></div>
C++ Program to Calculate the Inverse of matrix. This program finds the inverse of a matrix and prints the result on the
compiler screen. We define a 3-dimensional array 'a' of int type. It is
input by the user. The number of rows and columns are made fixed as 3.
Firstly determinant of the matrix is calculated using nested for loops
<br />
<a name='more'></a>and if determinant is equal to zero inverse does not exists and error
message is displayed otherwise inverse is printed on the compiler
screen.<br />
<br />
<u><b>Source Code:- </b></u><br />
<br />
<span style="color: blue;"><span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span><br />void main()<br />{int a[3][3],i,j;<br /> float determinant=0;<br /> clrscr();<br /> cout<<"Find Inverse Of Matrix by-Tarun Rawat\n";<br /> cout<<"Enter elements of 3x3 matrix:\n";<br /> for(i=0;i<3;i++)<br /> {<br /> for(j=0;j<3;j++)<br /> {<br /> cin>>a[i][j];<br /> }<br /> }<br /> cout<<"\nThe entered matrix is:\n";<br /> for(i=0;i<3;i++)<br /> {<br /> for(j=0;j<3;j++)<br /> {<br /> cout<<a[i][j]<<" ";<br /> }<br /> cout<<"\n";<br /> }<br /> for(i=0;i<3;i++)<br /> {<br /> determinant = determinant + (a[0][i]*(a[1][(i+1)%3]*<br /> a[2][(i+2)%3] - a[1][(i+2)%3]*a[2][(i+1)%3]));<br /> }<br /> if(determinant==0)<br /> {<br /> cout<<"Inverse does not exist (Determinant=0).\n";<br /> }<br /> else<br /> {<br /> cout<<"\nInverse of matrix is: \n";<br /> }<br /> for(i=0;i<3;i++)<br /> {<br /> for(j=0;j<3;j++)<br /> {<br /> cout<<(a[(i+1)%3][(j+1)%3] *<br /> a[(i+2)%3][(j+2)%3]) - (a[(i+1)%3][(j+2)%3]*<br /> a[(i+2)%3][(j+1)%3]))/ determinant<<"\t";<br /> }<br /> cout<<"\n";<br /> }<br /><br /> getch();<br />}</span></div>
Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com1tag:blogger.com,1999:blog-3770499729720157846.post-16946999483424104032014-03-16T11:24:00.001-07:002014-05-03T01:45:55.214-07:00Multiply Matrices by Strassen's Method<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH9VIW-VO1mHGEdF8N2jSUxKfcYUUI-rNNyyjFddJw8D6qjUvfkrBXH1MzL9yCSrGyYLJhhZC1CoZxPXnhi8RZKvjEoWJh9x_wovfoilC1fm1CaFb798HwVvSTZdVUsWwyzCbf3Z15_bwH/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH9VIW-VO1mHGEdF8N2jSUxKfcYUUI-rNNyyjFddJw8D6qjUvfkrBXH1MzL9yCSrGyYLJhhZC1CoZxPXnhi8RZKvjEoWJh9x_wovfoilC1fm1CaFb798HwVvSTZdVUsWwyzCbf3Z15_bwH/s1600/Untitled.jpg" height="125" width="200" /></a></div>
C++ Program to multiply matrix using Strassen's
Multiplication method. This program calculates the multiplication of 2 matrices by Strassen's
Multiplication method. We define a 3 arrays : 'a' , 'b' & 'c' , all
of int type. All 3 are input by the user. The number of rows &
columns are made fix to 2. Then the multiplication is calculated by
using strassen's method and the new multiplied matrix is printed on the
screen.<br />
<a name='more'></a><u><b>Source Code:-</b></u><br />
<br />
<span style="color: blue;"><span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span><br />void main()<br />{int a[2][2],b[2][2],c[2][2];<br /> int m1,m2,m3,m4,m5,m6,m7,i,j;<br /> clrscr();<br /> cout<<"Matrix Multiplication Strassrn's method by-Tarun Rawat\n";<br /> cout<<"Enter the elements of 2x2 Matrix 1:\n";<br /> for(i=0;i<2;i++)<br /> {<br /> for(j=0;j<2;j++)<br /> {<br /> cin>>a[i][j];<br /> }<br /> }<br /> cout<<"Enter the elements of 2x2 Matrix 2:\n";<br /> for(i=0;i<2;i++)<br /> {<br /> for(j=0;j<2;j++)<br /> {<br /> cin>>b[i][j];<br /> }<br /> }<br /> clrscr();<br /> cout<<"\nFirst matrix is:\n";<br /> for(i=0;i<2;i++)<br /> {<br /> for(j=0;j<2;j++)<br /> {<br /> cout<<a[i][j];<br /> }<br /> cout<<"\n";<br /> }<br /> cout<<"\nSecond matrix is\n";<br /> for(i=0;i<2;i++)<br /> {<br /> for(j=0;j<2;j++)<br /> {<br /> cout<<b[i][j];<br /> }<br /> cout<<"\n";<br /> }<br /> m1= (a[0][0] + a[1][1])*(b[0][0]+b[1][1]);<br /> m2= (a[1][0]+a[1][1])*b[0][0];<br /> m3= a[0][0]*(b[0][1]-b[1][1]);<br /> m4= a[1][1]*(b[1][0]-b[0][0]);<br /> m5= (a[0][0]+a[0][1])*b[1][1];<br /> m6= (a[1][0]-a[0][0])*(b[0][0]+b[0][1]);<br /> m7= (a[0][1]-a[1][1])*(b[1][0]+b[1][1]);<br /> c[0][0]=m1+m4-m5+m7;<br /> c[0][1]=m3+m5;<br /> c[1][0]=m2+m4;<br /> c[1][1]=m1-m2+m3+m6;<br /> cout<<"\nProduct of both is:\n";<br /> for(i=0;i<2;i++)<br /> {<br /> for(j=0;j<2;j++)<br /> {<br /> cout<<c[i][j];<br /> }<br /> cout<<"\n";<br /> }<br /> getch();<br />}</span></div>
Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com1tag:blogger.com,1999:blog-3770499729720157846.post-60484134448363098912014-03-15T22:09:00.002-07:002014-03-15T22:09:42.927-07:00QUEUE operations using Array<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8cwUafHZqM8_eqGvUM9Frs7okki6neCG_VGnNjgAPQVjJhIM7giPtMfydUwZmSPjXkRwKL_ZKbh8t1vJ0KdtqSRUFy6ddu1DU94YbP1v9EDFFfM__zcPYDsW5Yip_Sy0wToUPgoeqMjWf/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8cwUafHZqM8_eqGvUM9Frs7okki6neCG_VGnNjgAPQVjJhIM7giPtMfydUwZmSPjXkRwKL_ZKbh8t1vJ0KdtqSRUFy6ddu1DU94YbP1v9EDFFfM__zcPYDsW5Yip_Sy0wToUPgoeqMjWf/s1600/Untitled.jpg" height="130" width="200" /></a></div>
C++ Program for the implementation of Linear Queue operation (insert, delete & display). C++ Program to implement QUEUE operations using Array.
Queue is a abstract data type, In which entities are inserted into the rear end and deleted from the front end. <br />
Queue based on the FIFO (First In First Out) criteria,means the element inserted first is get deleted first. <br />
<a name='more'></a><br />
<u><b>Source Code:-</b></u><br />
<span style="color: cyan;"><br /></span>
<span style="color: blue;"><span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span> </span><br />
<span style="color: blue;">int queue[100],front=-1,rear=-1,max;<br />void insert_element();<br />void delete_element();<br />void display_queue();</span><br />
<br />
<span style="color: blue;">void main()<br />{ clrscr();<br /> int option;<br /> cout<<"Implement Queue operations by-Tarun Rawat\n\n";<br /> cout<<"Enter the size of Queue : ";<br /> cin>>max;<br /> do<br /> {cout<<"1.Insert an element";<br /> cout<<"\n2.Delete an element";<br /> cout<<"\n3.Display queue";<br /> cout<<"\n4.Exit";<br /> cout<<"\nEnter your choice : ";<br /> cin>>option;<br /> switch(option)<br /> { case 1: insert_element();<br /> break;<br /> case 2: delete_element();<br /> break;<br /> case 3: display_queue();<br /> break;<br /> case 4: return 0;<br /> }<br /> }while(option!=4);</span><br />
<span style="color: blue;">getch();<br />}</span><br />
<span style="color: blue;"><br />void insert_element()<br />{<br /> int num;<br /> cout<<"\nEnter the item to be inserted : ";<br /> cin>>num;<br /> if(front==0 && rear==max-1)<br /> cout<<"\nQueue OverFlow Occured\n";<br /> else if(front==-1&&rear==-1)<br /> {<br /> front=rear=0;<br /> queue[rear]=num;<br /><br /> }<br /> else if(rear==max-1 && front!=0)<br /> {<br /> rear=0;<br /> queue[rear]=num;<br /> }<br /> else<br /> {<br /> rear++;<br /> queue[rear]=num;<br /> }<br />}<br />void delete_element()<br />{<br /> int element;<br /> if(front==-1)<br /> {<br /> cout<<"\nUnderflow\n";<br /> }<br /> element=queue[front];<br /> if(front==rear)<br /> front=rear=-1;<br /> else<br /> {<br /> if(front==max-1)<br /> front=0;<br /> else<br /> front++;<br /> cout<<"\nThe deleted element is : "<<element;<br /> }<br /><br />}<br />void display_queue()<br />{<br /> int i;<br /> if(front==-1)<br /> cout<<"\nNo elements to display";<br /> else<br /> {<br /> cout<<"\nThe queue elements are :\n";<br /> for(i=front;i<=rear;i++)<br /> {<br /> cout<<"\t"<<queue[i];<br /> }<br /> }<br />}</span>Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com5tag:blogger.com,1999:blog-3770499729720157846.post-8079448364955332962014-03-15T21:57:00.000-07:002014-03-15T21:57:05.608-07:00Stack Operations using arrays<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipVcD1Cwlnt1pX4E4YM6lq0X0SS9yeuLRb5gosw24BUKxkfJmvYkuda0QD1lTNJQU94TNMnmKMDyZ7tBhUx56fmv9-tyXJj0KPqUj3D3DXFVE1b5gPy2wAJH3QGZt2LMmdjxF6vrLntuJF/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipVcD1Cwlnt1pX4E4YM6lq0X0SS9yeuLRb5gosw24BUKxkfJmvYkuda0QD1lTNJQU94TNMnmKMDyZ7tBhUx56fmv9-tyXJj0KPqUj3D3DXFVE1b5gPy2wAJH3QGZt2LMmdjxF6vrLntuJF/s1600/Untitled.jpg" height="131" width="200" /></a></div>
C++ program for implementation of Stack (push,pop & display) operation.Stack based on the LIFO (Last In First Out) behavior means, the last
element is pushed(insert) inside the stack , is the first element to get
pop(deleted).Stack is a data structure in which the objects are arranged in a non linear order.
In stack, elements are added or deleted from only one end, i.e. top of the stack.
Here we implement the PUSH, POP, DISPLAY stack operations using the array.<br />
<a name='more'></a><u><b>Source Code:-</b></u><br />
<br />
<br />
<span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span><br /><span style="color: blue;">int stack[20],top=-1; //global declaration<br />void push();<br />void pop();<br />void display();<br />void main()<br />{ clrscr();<br /> int ch;<br /> cout<<"Program for Stack Operations by-Tarun Rawat\n\n";<br /> do<br /> { cout<<"\n1.Push";<br /> cout<<"\n2.Pop";<br /> cout<<"\n3.Display";<br /> cout<<"\n4.Exit";<br /> cout<<"\nEnter your choice : ";<br /> cin>>ch;<br /> if(ch==1)<br /> push();<br /> else if(ch==2)<br /> pop();<br /> else if(ch==3)<br /> display();<br /> else if(ch==4)<br /> cout<<"\nEnd Of program";<br /> }while(ch!=4);<br />}<br />//to push elements in a stack<br />void push()<br />{<br /> if(top>9)<br /> cout<<"\nStack Overflow";<br /> else<br /> { top=top+1;<br /> cout<<"\nEnter a value : ";<br /> cin>>stack[top];<br /> }<br /><br />}<br /><br />//to pop/delete stack elements<br />void pop()<br />{<br /> if(top==-1)<br /> cout<<"\nStack Overflow. No Elements to pop";<br /> else<br /> {<br /> cout<<stack[top]<<" is deleted..";<br /> top--;<br /> }<br />}<br /><br />//displaying stack elements<br />void display()<br />{<br /> int i;<br /> if(top==-1)<br /> cout<<"\nStack underflow. No elements to display..";<br /> else<br /> {<br /> cout<<"\nThe stack elements are : ";<br /> for(i=0;i<=top;i++)<br /> {<br /> cout<<"\t"<<stack[i];<br /> }<br /> cout<<"\n";<br /><br /> }<br />}</span>Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com1tag:blogger.com,1999:blog-3770499729720157846.post-84498519498910556942014-03-14T07:23:00.003-07:002014-03-17T01:14:26.833-07:00check Armstrong number<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgueQlIEg0mV28Rgo-o7PkP6PUlcm4A4l3SnEpXLPKuTzAkpXvo14XPD6tbsQtfH-5PTGgdk1MpyUJ68Z_z6hF2rDzGyi7YGEP74RGcqFsrDe5r-Fltx9Qzm6R3U20SAPbQzqb7Ir520Ra4/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgueQlIEg0mV28Rgo-o7PkP6PUlcm4A4l3SnEpXLPKuTzAkpXvo14XPD6tbsQtfH-5PTGgdk1MpyUJ68Z_z6hF2rDzGyi7YGEP74RGcqFsrDe5r-Fltx9Qzm6R3U20SAPbQzqb7Ir520Ra4/s1600/Untitled.jpg" height="120" width="200" /></a></div>
C++ Program to check the input number is Armstrong number or not.<br />
Armstrong number c++ program: A number is armstrong if the sum of cubes of
individual digits of a number is equal to the number itself. For example
371 is an armstrong number as 3<sup>3</sup> + 7<sup>3</sup> + 1<sup>3</sup> = 371. Some other armstrong numbers are: 0, 1, 153, 370, 407. <br />
<a name='more'></a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj989UuhAcfuZPhmXEn-41clkbPNVx0JQ8eMLcpHgZAi1wKNrcbyhIZiLfqp0z0A5kcaqwBHVJYPUGuy_so40QCf2lPdjQPodDK1dmsu7oEfedJ63G6qnWm5Z-Fq82hxcg4yI0OPG4qZ-UY/s1600/Untitlzed.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj989UuhAcfuZPhmXEn-41clkbPNVx0JQ8eMLcpHgZAi1wKNrcbyhIZiLfqp0z0A5kcaqwBHVJYPUGuy_so40QCf2lPdjQPodDK1dmsu7oEfedJ63G6qnWm5Z-Fq82hxcg4yI0OPG4qZ-UY/s1600/Untitlzed.jpg" height="120" width="400" /></a></div>
<u><b>Source Code:-</b></u><br />
<br />
<br />
<span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span><br />
<span style="color: blue;">void main()<br />{ clrscr();<br /> int temp,num,sum=0,r;<br /> cout<<"Program to check Armstrong condition by-Tarun Rawat\n\n";<br /> cout<<"Enter a number : ";<br /> cin>>num;<br /> temp=num;<br /> while(num!=0)<br /> {r=num%10;<br /> num=num/10;<br /> sum=sum+(r*r*r);<br /> }<br /> if(sum==temp)<br /> cout<<endl<<temp<<" is a Armstrong number. \n";<br /> else cout<<endl<<temp<<" is not a Armstrong number./n";<br />getch();<br />}</span>Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com3tag:blogger.com,1999:blog-3770499729720157846.post-35944158179666121112014-03-14T07:15:00.000-07:002014-03-14T23:43:41.850-07:00Transpose a matrix <div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqtxeL7ZiUfga0iYIXj8XAG1XL9xdCu1gDbx9nT0XfSkjhVR6-3qAaqssdb0OQhsNOq0qi69S-6vMVsJic5q2WEjd56Lj7UagqqNO96XHUt3qwRNC1ZjSr16oACt7JySNlYdIJpv5kR1Ov/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqtxeL7ZiUfga0iYIXj8XAG1XL9xdCu1gDbx9nT0XfSkjhVR6-3qAaqssdb0OQhsNOq0qi69S-6vMVsJic5q2WEjd56Lj7UagqqNO96XHUt3qwRNC1ZjSr16oACt7JySNlYdIJpv5kR1Ov/s1600/Untitled.jpg" height="91" width="200" /></a></div>
C++ Program fot the Transpose of matrix.This c++ program prints transpose of a matrix. It is obtained by
interchanging rows and columns of a matrix. When we transpose a matrix then the order of matrix changes, but for a square matrix order remains same.<br />
<a name='more'></a><br />
<br />
<u><b>Source Code:-</b></u><br />
<br />
<span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span><br />
<br />
<span style="color: blue;">void main()<br />{clrscr();<br /> int a[10][10],b[10][10],i,j,m,n;<br /> cout<<"Program for Transpose of Matrix by-Tarun Rawat\n\n";<br /> cout<<"Enter number of row in matrix : ";<br /> cin>>m;<br /> cout<<"Enter number of column in matrix : ";<br /> cin>>n;<br /> cout<<"\nEnter elements in an matrix : ";<br /><br /> for(i=0;i<m;i++)<br /> {for(j=0;j<n;j++)<br /> {cin>>a[i][j];<br /> }<br /> }<br /> cout<<"\nInput matrix : \n";<br /> for(i=0;i<m;i++)<br /> {for(j=0;j<n;j++)<br /> {cout<<a[i][j]<<" ";<br /> }<br /> cout<<"\n";<br /> }<br /><br /> for(i=0;i<m;i++)<br /> {for(j=0;j<n;j++)<br /> {b[i][j]=a[j][i];<br /> }<br /> }<br /> cout<<"\nTranspose matrix : \n";<br /> for(i=0;i<m;i++)<br /> {for(j=0;j<n;j++)<br /> {cout<<b[i][j]<<" ";<br /> }<br /> cout<<"\n";<br /> }<br />getch();<br />}</span>Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com2tag:blogger.com,1999:blog-3770499729720157846.post-43650199256598034912014-03-09T08:48:00.001-07:002014-03-14T23:43:31.590-07:00Convert Binary to Decimal or Decimal to Binary<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_jxgFdfGalesq7VflwTuFOzniPihS0O1JfFXgseRnmR0d6UJ2uGAcDlftvFNpStBrQx9Mcqc_E8Q9tCdgBUIDQwvj4O9El1Up0Ru7DVsXav8qdxBI5FwCuwAqbHxW081vk9Y_JT8ZMN6N/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_jxgFdfGalesq7VflwTuFOzniPihS0O1JfFXgseRnmR0d6UJ2uGAcDlftvFNpStBrQx9Mcqc_E8Q9tCdgBUIDQwvj4O9El1Up0Ru7DVsXav8qdxBI5FwCuwAqbHxW081vk9Y_JT8ZMN6N/s1600/Untitled.jpg" height="99" width="320" /></a></div>
C++ Program to convert Binary number to Decimal number or vice versa.This program converts either binary number entered by user to decimal
number or decimal number entered by user to binary number in accordance
with the character entered by user.This program asks user to enter alphabet 'b' to convert <br />
<a name='more'></a>decimal
number to binary and alphabet 'd' to convert binary number to decimal.<br />
In accordance with the character entered, user is asked to enter either
binary value to convert to decimal or decimal value to convert to
binary.To perform conversion, two functions are made <code>decimal_binary()</code>; to convert decimal to binary and <code>binary_decimal()</code>; to convert binary to decimal. Decimal number entered by user is passed to <code>decimal_binary()</code> and this function computes the binary value of that number and returns it <code>main()</code> function. Similarly, binary number is passed to function <code>binary_decimal()</code> and this function computes decimal value of that number and returns it to <code>main()</code> function.<br />
<br />
<u><b>Source Code:- </b></u><br />
<span style="color: blue;"><br /></span>
<span style="color: blue;"><span style="color: #cc0000;">#include <iostream.h><br />#include <conio.h><br />#include <math.h></span><br />int binary_decimal(int n);<br />int decimal_binary(int n);<br />int main()<br />{ clrscr();<br /> int n;<br /> char c;<br /> cout<<"Convet Decimal to Binary & vice versa by-Tarun Rawat\n\n";<br /> cout<<"1. Enter alphabet 'd' to convert binary to decimal.\n";<br /> cout<<"2. Enter alphabet 'b' to convert decimal to binary.\n";<br /> cin>>c;<br /> if (c =='d' || c == 'D')<br /> { cout<<"\nEnter a binary number : ";<br /> cin>>n;<br /> cout<<n<<" in binary = "<<binary_decimal(n)<<" in decimal";<br /> }<br /> if (c =='b' || c == 'B')<br /> { cout<<"\nEnter a decimal number : ";<br /> cin>>n;<br /> cout<<n<<" in decimal = "<<decimal_binary(n)<<" in binary";<br /> }<br />getch();<br />}<br /><br />int decimal_binary(int n) /* Function to convert decimal to binary.*/<br />{ int rem, i=1, binary=0;<br /> while (n!=0)<br /> { rem=n%2;<br /> n/=2;<br /> binary+=rem*i;<br /> i*=10;<br /> }<br /> return binary;<br />}<br /><br />int binary_decimal(int n) /* Function to convert binary to decimal.*/<br />{ int decimal=0, i=0, rem;<br /> while (n!=0)<br /> { rem = n%10;<br /> n/=10;<br /> decimal += rem*pow(2,i);<br /> ++i;<br /> }<br /> return decimal;<br />}</span>Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com2tag:blogger.com,1999:blog-3770499729720157846.post-46794139352548409722014-03-09T08:41:00.003-07:002014-03-17T01:11:59.985-07:00Calculate Average Using Arrays<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWv-BG4iI6-mo7ZoZruwIsd0BXWgwaIEzbyWRvFyl_0SjtgIImR8dkgztdpnAI7yDp9JXgaQCG5vp59JXjAGdOGoHWGYTgLGfJMv3NMHnwuHYL2TGBxwvnm3wXJDH9-MFRKAf-xvOyRynm/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWv-BG4iI6-mo7ZoZruwIsd0BXWgwaIEzbyWRvFyl_0SjtgIImR8dkgztdpnAI7yDp9JXgaQCG5vp59JXjAGdOGoHWGYTgLGfJMv3NMHnwuHYL2TGBxwvnm3wXJDH9-MFRKAf-xvOyRynm/s1600/Untitled.jpg" height="120" width="200" /></a></div>
C++ Program to Calculate Average of n number, using array.This program takes <var>n</var> number of element from user(where, n is
specified by user), stores data in an array and calculates the average
of those numbers.This program calculates the average if the number of data are from 1 to 100. If user enters value of <var>n</var> above 100 or below 100 then, while loop is executed which asks user to enter value of <var>n</var> until it is between 1 and 100.<br />
<a name='more'></a><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj25mDDnaab-znbAKda46Kc9JBwsoxbTk5UrURgF0tjnjpL-zAGeOlev7_MVa1noQEvsq1RMwt83_MxzsIn_m8V7T3XK5wcQK17X8MBHxsPjJXCVfaXxaTcfsyFfldpTbYIJJiKOetoqrGU/s1600/Untitxled.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj25mDDnaab-znbAKda46Kc9JBwsoxbTk5UrURgF0tjnjpL-zAGeOlev7_MVa1noQEvsq1RMwt83_MxzsIn_m8V7T3XK5wcQK17X8MBHxsPjJXCVfaXxaTcfsyFfldpTbYIJJiKOetoqrGU/s1600/Untitxled.jpg" height="104" width="320" /></a></div>
<u><b>Source Code:-</b></u><br />
<br />
<span style="color: blue;"><span style="color: #cc0000;">#include <iostream.h><br />#include <conio.h></span><br />int main()<br />{ clrscr();<br /> int n, i;<br /> float num[100], sum=0.0, average;<br /> cout<<"Program to calculate Average using array by-Tarun Rawat\n\n";<br /> cout<<"Enter the numbers of data : ";<br /> cin>>n;<br /> while (n>100 || n<=0)<br /> { cout<<"Error! number should in range of (1 to 100).\n";<br /> cout<<"Enter the number again : ";<br /> cin>>n;<br /> }<br /> for(i=0; i<n; ++i)<br /> {<br /> cout<<i+1<<" Enter number : ";<br /> cin>>num[i];<br /> sum+=num[i];<br /> }<br /> average=sum/n;<br /> cout<<"Average = "<<average;<br />getch();<br />}</span>Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com0tag:blogger.com,1999:blog-3770499729720157846.post-23545551103299481512014-03-09T08:36:00.001-07:002014-03-17T01:14:26.772-07:00Count Number of Digits of an Integer<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKMRQiZxjiuS_Yydq6hThVqwGXPKnZ4LJheZjoYIwuC6Po6WYW4uuZ3qdSH_Ru3Zp7xigZiZgYlEfF6OEaRPqZ0oaWDraOEklrZsRzeHzHuAz8psyEY1S4lcZhToFDkTKYyLRkh-Oa-ADl/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKMRQiZxjiuS_Yydq6hThVqwGXPKnZ4LJheZjoYIwuC6Po6WYW4uuZ3qdSH_Ru3Zp7xigZiZgYlEfF6OEaRPqZ0oaWDraOEklrZsRzeHzHuAz8psyEY1S4lcZhToFDkTKYyLRkh-Oa-ADl/s1600/Untitled.jpg" height="119" width="200" /></a></div>
C++ program to count number of digit in an integer. This program takes an integer from user and calculates the number of
digits in that integer. For example: If user enters 2319, the output of
program will be 4 because it contains 4 digits.This program takes an integer from user and stores that number in variable <var>n</var>. Suppose, user entered 34523. Then, while loop is executed because <code>n!=0</code>
will be true in first iteration. <br />
<a name='more'></a>The codes inside while loop will be
executed. After first iteration, value of n will be 3452 and <var>count</var> will be 1. Similarly, in second iteration <var>n</var> will be equal to 345 and <var>count</var> will be equal to 2. This process goes on and after fourth iteration, n will be equal to 3 and <var>count</var> will be equal to 4. Then, in next iteration n will be equal to 0 and <var>count</var> will be equal to 5 and program will be terminated as <code>n!=0</code> becomes false. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTB1eBgfthoehUHw45xBGqf0MD5DsVEXyUHVftspNsfR3xTzEy3mJr-PaJJwme61bGWZQtTK2r2JgeZZLK5P36osQHelg1YtEJLaSmK2VFIJjBsO5a1PKPPu6hnKkuHNUCVzeqpK02NGkQ/s1600/Undtitled.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTB1eBgfthoehUHw45xBGqf0MD5DsVEXyUHVftspNsfR3xTzEy3mJr-PaJJwme61bGWZQtTK2r2JgeZZLK5P36osQHelg1YtEJLaSmK2VFIJjBsO5a1PKPPu6hnKkuHNUCVzeqpK02NGkQ/s1600/Undtitled.jpg" height="83" width="320" /></a></div>
<br />
<u><b>Source Code:-</b></u><br />
<br />
<span style="color: blue;"><span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span><br />void main()<br />{ clrscr();<br /> long int num1,count=0;<br /> cout<<"count number of digits in a number by-Tarun Rawat\n\n";<br /> cout<<"Enter number to count it's Digit : ";<br /> cin>>num1;<br /> while(num1!=0)<br /> {num1=num1/10;<br /> count++;<br /> }<br /> cout<<"Number of Digit is : "<<count;<br />getch();<br />}</span>Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com0tag:blogger.com,1999:blog-3770499729720157846.post-68713798907838185082014-03-09T08:32:00.000-07:002014-03-17T01:14:26.824-07:00Find HCF of two number<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiFVmldck_lEPUY4jaFANxSTEJzlkyd0TzmUMjQmANjsFL9zVG5zwl3yFJQD-NsNSvWEILIzKjngQVBhM8pse71QjNBz1UqH9NDt3q6BJoT_i_JRUuQbKp2AeeccxIf7bn2Td_u40IHYS5/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiFVmldck_lEPUY4jaFANxSTEJzlkyd0TzmUMjQmANjsFL9zVG5zwl3yFJQD-NsNSvWEILIzKjngQVBhM8pse71QjNBz1UqH9NDt3q6BJoT_i_JRUuQbKp2AeeccxIf7bn2Td_u40IHYS5/s1600/Untitled.jpg" height="120" width="200" /></a></div>
C++ Program to find HCF of two number.<br />
The largest integer which is perfectly divisible to two or more numbers is known as <abbr title="Highest Common Factor">H.C.F</abbr> or <abbr title="Greatest Common Divisor">G.C.D</abbr> of those two numbers.There
are many ways to find the H.C.F of two numbers is C++ programming. Below code will take two integers from user and displays the H.C.F of
those two integers.This is the best way to find HCF of two numbers. <br />
<a name='more'></a>In this method, smaller
number is subtracted from larger number and that number is stored in
place of larger number. This process is continued until, two numbers
become equal which will be HCF.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGLE0I6aIza2jmtcNZzOFFCkXd6ea5XEU-QhrBj4_IyjQEIdLv38-PoEcz4sUTri3jmu4sHU39LUrDDOdLnnUZe38LlWXhAKSMkJTGa-hcUps4d0bg1iP-dkDLM000prFqAjkceabMad-H/s1600/Untitdled.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGLE0I6aIza2jmtcNZzOFFCkXd6ea5XEU-QhrBj4_IyjQEIdLv38-PoEcz4sUTri3jmu4sHU39LUrDDOdLnnUZe38LlWXhAKSMkJTGa-hcUps4d0bg1iP-dkDLM000prFqAjkceabMad-H/s1600/Untitdled.jpg" height="63" width="200" /></a></div>
<u><b>Source Code:-</b></u><br />
<br />
<span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h><br /><span style="color: blue;">void main()<br />{ clrscr();<br /> int num1,num2;<br /> cout<<" Find HCF of two number by-Tarun Rawat\n\n";<br /> cout<<"Enter first number : ";<br /> cin>>num1;<br /> cout<<"Enter second number : ";<br /> cin>>num2;<br /> cout<<"HCF of "<<num1<<" & "<<num2<<" is : ";<br /> while(num1!=num2)<br /> {if(num1>num2)<br /> num1-=num2;<br /> else num2-=num1;<br /> }<br /> cout<<num1;<br /> getch();<br />}</span></span><br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com0tag:blogger.com,1999:blog-3770499729720157846.post-3474969338308393252014-03-09T08:27:00.003-07:002014-03-17T01:14:26.790-07:00Swap two Numbers<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ8npU3aXWJqyoSClMD33UprOWVMcvbFzjJDyvl-bmffzPVcpC-Y0WFXHaXDhVzEC8vjyPNd-__02c5jT5s3quLfxsBUXRFRM-X38fTzM70PFUR4PSKJSrHTquzQ9FbU9nrsHiGCPULN9D/s1600/Untitled.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ8npU3aXWJqyoSClMD33UprOWVMcvbFzjJDyvl-bmffzPVcpC-Y0WFXHaXDhVzEC8vjyPNd-__02c5jT5s3quLfxsBUXRFRM-X38fTzM70PFUR4PSKJSrHTquzQ9FbU9nrsHiGCPULN9D/s1600/Untitled.jpg" height="120" width="200" /></a></div>
C++ Program to Swap to integer value.This program asks user to enter two numbers and this program will swap the value of these two numbers.<br />
Simply use oh three variable as shown in the program a, b & temp.<br />
external variable temp is use to hold the value of a so that it can be use to assign value to b variable.<br />
<a name='more'></a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio-n1ofqa5cgSKJYcKKx-WHIZR_v8TTWsRBmowYySWbLPk-Tx4mE9PeA77dbZ3r7fbUKfyX4uEDFi1R8YX4YUERJPxyrhnorm_wLDp8UN3x4azFFWMzTp8KDDB3fDQsbliKytFR7OhqFdD/s1600/Untitledd.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio-n1ofqa5cgSKJYcKKx-WHIZR_v8TTWsRBmowYySWbLPk-Tx4mE9PeA77dbZ3r7fbUKfyX4uEDFi1R8YX4YUERJPxyrhnorm_wLDp8UN3x4azFFWMzTp8KDDB3fDQsbliKytFR7OhqFdD/s1600/Untitledd.jpg" height="129" width="320" /></a></div>
<u><b>Source Code:-</b></u><br />
<br />
<span style="color: blue;"><span style="color: #cc0000;">#include<iostream.h><br />#include<conio.h></span> </span><br />
<span style="color: blue;">void main()<br />{clrscr();<br /> int a,b,temp=0;<br /> cout<<"Program to swap two number by-Tarun Rawat\n\n";<br /> cout<<"Enter first number (let a) : ";<br /> cin>>a;<br /> cout<<"\nEnter second number (let b) : ";<br /> cin>>b;<br /> temp=a;<br /> a=b;<br /> b=temp;<br /> cout<<"\nAfter swap :- ";<br /> cout<<"\n\t\tValue of a is : "<<a<<"\n\n\t\tValue of b is : "<<b;<br />getch();<br />}</span>Anonymoushttp://www.blogger.com/profile/14105844263113059307noreply@blogger.com0