<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7840352491082926975</id><updated>2025-06-02T11:45:41.256-07:00</updated><title type='text'>Programming in C++</title><subtitle type='html'>All these programs belongs to JNTU MCA I Semester syllabus for OBJECT ORIENTED PROGRAMMING(THROUGH C++) LAB</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cppprogramskills.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default'/><link rel='alternate' type='text/html' href='http://cppprogramskills.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>shriram ( శ్రీరాం )</name><uri>http://www.blogger.com/profile/00971680137941932814</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGTlINONrq0VczLe2nPfmnrOEp3kK1D880NQXzT0hz59E7WS8_-7ly0v4zUNy2OFEuE7TfreKF1GWOKDQNm5yMPgo4U2PYutO8ALaZX8vd5nD7HjzNRiUurQZsK5KOX8/s220/Photo0007.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7840352491082926975.post-3062417950840430856</id><published>2009-03-02T05:54:00.000-08:00</published><updated>2009-03-02T06:27:01.390-08:00</updated><title type='text'>Write a C++ program to sort a list of names in ascending order.</title><content type='html'>#include(iostream.h)&lt;br /&gt;#include(conio.h)&lt;br /&gt;#include(stdio.h)&lt;br /&gt;#include(string.h)&lt;br /&gt;void main()&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;char st[10][10],temp[10];&lt;br /&gt;int i, j, n;&lt;br /&gt;clrscr();&lt;br /&gt;cout&lt;&lt;&quot;Enter the no. of names:&quot;;&lt;br /&gt;cin&gt;&gt;n;&lt;br /&gt;cout&lt;&lt;&quot;Enter the different names:&quot;;&lt;br /&gt;for(i=0; i&lt; n; i++)&lt;br /&gt;cin&gt;&gt;st[i];&lt;br /&gt;for(i=0; i&lt; n; i++)&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;for(j=i; j&lt; n-1; j++)&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 255, 51);&quot;&gt;{ &lt;/span&gt;&lt;br /&gt;if(strcmp(st[i], st[j+1]) &gt;0)&lt;br /&gt;{&lt;br /&gt;strcpy(temp,st[i]);&lt;br /&gt;strcpy(st[i],st[j+1]);&lt;br /&gt;strcpy(st[j+1],temp);&lt;br /&gt;}&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 255, 51);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;cout&lt;&lt;&quot;Given names after ascending order:&quot;;&lt;br /&gt;for(i=0;i&lt;5;i++)&lt;br /&gt;cout&lt;&lt; st[i];&lt;br /&gt;getch();&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Output&lt;/span&gt;: Enter the no.of names: 5&lt;br /&gt;&lt;br /&gt;Enter the different names: apple&lt;br /&gt;cat&lt;br /&gt;boy&lt;br /&gt;apec&lt;br /&gt;suresh&lt;br /&gt;&lt;br /&gt;Given names after ascending order:&lt;br /&gt;apec&lt;br /&gt;apple&lt;br /&gt;boy&lt;br /&gt;cat&lt;br /&gt;suresh&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Note&lt;/span&gt;:- If u have any doubt regarding this program &lt;a style=&quot;background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;&quot; name=&quot;AdBriteInlineAd_program&quot; id=&quot;AdBriteInlineAd_program&quot; target=&quot;_top&quot;&gt;&lt;/a&gt;&lt;span&gt; or logic, please feel free to contact me. &lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://cppprogramskills.blogspot.com/feeds/3062417950840430856/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cppprogramskills.blogspot.com/2009/03/write-c-program-to-sort-list-of-names.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/3062417950840430856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/3062417950840430856'/><link rel='alternate' type='text/html' href='http://cppprogramskills.blogspot.com/2009/03/write-c-program-to-sort-list-of-names.html' title='Write a C++ program to sort a list of names in ascending order.'/><author><name>shriram ( శ్రీరాం )</name><uri>http://www.blogger.com/profile/00971680137941932814</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGTlINONrq0VczLe2nPfmnrOEp3kK1D880NQXzT0hz59E7WS8_-7ly0v4zUNy2OFEuE7TfreKF1GWOKDQNm5yMPgo4U2PYutO8ALaZX8vd5nD7HjzNRiUurQZsK5KOX8/s220/Photo0007.jpg'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7840352491082926975.post-4013204793952511906</id><published>2009-02-27T21:31:00.000-08:00</published><updated>2009-02-27T22:06:23.183-08:00</updated><title type='text'>Write a C++ program to count the lines, words and characters in a given text.</title><content type='html'>#include(iostream.h)&lt;br /&gt;#include(conio.h)&lt;br /&gt;#include(stdio.h)&lt;br /&gt;void main( )&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;char ch;&lt;br /&gt;int sp=0, ct=0, line=0;&lt;br /&gt;clrscr( );&lt;br /&gt;cout&lt;&lt;&quot;Enter the required lines of text:&quot;;&lt;br /&gt;while((ch=getchar())!=EOF)&lt;br /&gt;{&lt;br /&gt;ct++;&lt;br /&gt;if((ch==&#39; &#39;)&lt;br /&gt;sp++;&lt;br /&gt;if(ch==&#39;\n&#39;)&lt;br /&gt;line++;&lt;br /&gt;}&lt;br /&gt;cout&lt;&lt;&quot;Total Lines:&quot;&lt;&lt; line;&lt;br /&gt;cout&lt;&lt;&quot;Total words:&quot;&lt;&lt; sp+line;&lt;br /&gt;cout&lt;&lt;&quot;Total Characters:&quot;&lt;&lt; ct;&lt;br /&gt;getch( );&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Output&lt;/span&gt;:- Enter the required lines of text:&lt;br /&gt;Where are you&lt;br /&gt;Come fast&lt;br /&gt;^z&lt;br /&gt;&lt;br /&gt;Total Lines: 2&lt;br /&gt;Total words: 5&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Note&lt;/span&gt;:- If u have any doubt regarding this program &lt;a style=&quot;background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;&quot; name=&quot;AdBriteInlineAd_program&quot; id=&quot;AdBriteInlineAd_program&quot; target=&quot;_top&quot;&gt;&lt;/a&gt; or logic, please feel free to contact me.</content><link rel='replies' type='application/atom+xml' href='http://cppprogramskills.blogspot.com/feeds/4013204793952511906/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-to-count-lines-words.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/4013204793952511906'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/4013204793952511906'/><link rel='alternate' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-to-count-lines-words.html' title='Write a C++ program to count the lines, words and characters in a given text.'/><author><name>shriram ( శ్రీరాం )</name><uri>http://www.blogger.com/profile/00971680137941932814</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGTlINONrq0VczLe2nPfmnrOEp3kK1D880NQXzT0hz59E7WS8_-7ly0v4zUNy2OFEuE7TfreKF1GWOKDQNm5yMPgo4U2PYutO8ALaZX8vd5nD7HjzNRiUurQZsK5KOX8/s220/Photo0007.jpg'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7840352491082926975.post-6907436186827841436</id><published>2009-02-27T21:11:00.000-08:00</published><updated>2009-02-27T21:28:09.109-08:00</updated><title type='text'>Write a C++ program to make the frequency count of letters in a given text.</title><content type='html'>#include(iostream.h) // place this &#39;&lt;&#39; &amp;amp; &#39;&gt;&#39; instead of &#39;(&#39; &amp;amp; &#39;)&#39; before iostream.h&lt;br /&gt;#include(conio.h)&lt;br /&gt;#include(stdio.h)&lt;br /&gt;void main( )&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;chat st[80];&lt;br /&gt;int i, ct=0,sp=0;&lt;br /&gt;clrscr( );&lt;br /&gt;cout&lt;&lt;&quot;Enter the required information:&quot;;&lt;br /&gt;gets(st);  for(i=0; st[i]!=&#39;\0&#39;; i++)&lt;br /&gt;{&lt;br /&gt;ct++;&lt;br /&gt;if(st[i]==&#39; &#39;)&lt;br /&gt;sp++;&lt;br /&gt;}&lt;br /&gt;cout&lt;&lt;&quot;Total Letters present in the given text :&quot;&lt;&lt; ct-sp;&lt;br /&gt;getch( );&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here the variable &lt;span style=&quot;font-weight: bold;&quot;&gt;&#39;sp&#39;&lt;/span&gt; is for counting space and &lt;span style=&quot;font-weight: bold;&quot;&gt;&#39;ct&#39;&lt;/span&gt; is for counting characters.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Note&lt;/span&gt;:- If u have any doubt regarding this program &lt;a style=&quot;background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;&quot; name=&quot;AdBriteInlineAd_program&quot; id=&quot;AdBriteInlineAd_program&quot; target=&quot;_top&quot;&gt;&lt;/a&gt; or logic, please feel free to contact me.</content><link rel='replies' type='application/atom+xml' href='http://cppprogramskills.blogspot.com/feeds/6907436186827841436/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-to-make-frequency-count.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/6907436186827841436'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/6907436186827841436'/><link rel='alternate' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-to-make-frequency-count.html' title='Write a C++ program to make the frequency count of letters in a given text.'/><author><name>shriram ( శ్రీరాం )</name><uri>http://www.blogger.com/profile/00971680137941932814</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGTlINONrq0VczLe2nPfmnrOEp3kK1D880NQXzT0hz59E7WS8_-7ly0v4zUNy2OFEuE7TfreKF1GWOKDQNm5yMPgo4U2PYutO8ALaZX8vd5nD7HjzNRiUurQZsK5KOX8/s220/Photo0007.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7840352491082926975.post-4572174733612180153</id><published>2009-02-26T21:20:00.000-08:00</published><updated>2009-02-26T21:32:12.666-08:00</updated><title type='text'>Write a C++ program to sort a list of numbers in ascending order.</title><content type='html'>#include(iostream.h) // place this &#39;&lt;&#39; &amp;amp; &#39;&gt;&#39; instead of &#39;(&#39; &amp;amp; &#39;)&#39; before iostream.h&lt;br /&gt;#include(conio.h)&lt;br /&gt;void main( )&lt;br /&gt;{&lt;br /&gt;int a[10], n, i, j, temp;&lt;br /&gt;clrscr( );&lt;br /&gt;cout&lt;&lt;&quot;Enter the no. of elements:&quot;; &lt;br /&gt;cin&gt;&gt; n;&lt;br /&gt;cout&lt;&lt;&quot;Enter the array elements:&quot;;&lt;br /&gt;for(i=0; i&lt; n; i++)&lt;br /&gt;cin&gt;&gt;a[i];&lt;br /&gt;//------Operation part-------&lt;br /&gt;for( i=0; i&lt; n; i++)&lt;br /&gt;{&lt;br /&gt;for(j=i; j&lt; n-1; j++)&lt;br /&gt;{&lt;br /&gt;if(a[i]&gt; a[j+1] )&lt;br /&gt;{&lt;br /&gt;temp= a[i];&lt;br /&gt;a[i]= a[j+1];&lt;br /&gt;a[j+1]= temp;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;cout&lt;&lt;&quot;Elements after sorting:&quot;;&lt;br /&gt;for( i=0; i&lt; n; i++)&lt;br /&gt;cin&gt;&gt; a[i];&lt;br /&gt;&lt;n; cout=&quot;&quot;&gt;&lt;a[i]; of=&quot;&quot; 5=&quot;&quot; enter=&quot;&quot; the=&quot;&quot; array=&quot;&quot; elements=&quot;&quot; after=&quot;&quot; 1=&quot;&quot; 2=&quot;&quot; 4=&quot;&quot; 8=&quot;&quot; 90=&quot;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;getch ( );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Note&lt;/span&gt;:- If u have any doubt regarding this program &lt;a style=&quot;background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;&quot; name=&quot;AdBriteInlineAd_program&quot; id=&quot;AdBriteInlineAd_program&quot; target=&quot;_top&quot;&gt;&lt;/a&gt; or logic, please feel free to contact me.&lt;br /&gt;&lt;/a[i];&gt;&lt;/n;&gt;</content><link rel='replies' type='application/atom+xml' href='http://cppprogramskills.blogspot.com/feeds/4572174733612180153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-to-sort-list-of-numbers.html#comment-form' title='29 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/4572174733612180153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/4572174733612180153'/><link rel='alternate' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-to-sort-list-of-numbers.html' title='Write a C++ program to sort a list of numbers in ascending order.'/><author><name>shriram ( శ్రీరాం )</name><uri>http://www.blogger.com/profile/00971680137941932814</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGTlINONrq0VczLe2nPfmnrOEp3kK1D880NQXzT0hz59E7WS8_-7ly0v4zUNy2OFEuE7TfreKF1GWOKDQNm5yMPgo4U2PYutO8ALaZX8vd5nD7HjzNRiUurQZsK5KOX8/s220/Photo0007.jpg'/></author><thr:total>29</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7840352491082926975.post-658162083159745675</id><published>2009-02-26T21:10:00.000-08:00</published><updated>2009-02-26T21:20:19.581-08:00</updated><title type='text'>Write a C++ program to find both the largest and smallest number in a list of integers.</title><content type='html'>#include(iostream.h) // place this &#39;&lt;&#39; &amp;amp; &#39;&gt;&#39; instead of &#39;(&#39; &amp;amp; &#39;)&#39; before iostream.h&lt;br /&gt;#include(conio.h)&lt;br /&gt;void main(void)&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;{&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;int a[50], max, min, i, n;&lt;br /&gt;clrscr( );&lt;br /&gt;cout&lt;&lt;&quot;Enter how many integers do u want? :&quot;; cin&gt;&gt;n;&lt;br /&gt;for( i=0; i&lt; n ; i++)&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 102, 0);&quot;&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;cout&lt;&lt;&quot;Enter the numbers: &quot;;&lt;br /&gt; cin&gt;&gt;a[ i ];&lt;br /&gt;if(i==o) &lt;strong&gt;&lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;{&lt;/span&gt;&lt;/strong&gt; max=a[i ]; min=a[i ]; &lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;if(a[ i]&gt;max)&lt;br /&gt;max= a[i ];&lt;br /&gt;if(a[i ]&lt; min)&lt;br /&gt;min= a[i ];&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(255, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;cout&lt;&lt;&quot;Maximum : &quot;&lt;&lt; max;&lt;br /&gt;cout&lt;&lt;&quot;Minimum : &quot;&lt;&lt; min;&lt;br /&gt;getch( );&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Note&lt;/span&gt;:- If u have any doubt regarding this program &lt;a style=&quot;background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;&quot; name=&quot;AdBriteInlineAd_program&quot; id=&quot;AdBriteInlineAd_program&quot; target=&quot;_top&quot;&gt;&lt;/a&gt; or logic, please feel free to contact me.</content><link rel='replies' type='application/atom+xml' href='http://cppprogramskills.blogspot.com/feeds/658162083159745675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-to-find-both-largest.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/658162083159745675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/658162083159745675'/><link rel='alternate' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-to-find-both-largest.html' title='Write a C++ program to find both the largest and smallest number in a list of integers.'/><author><name>shriram ( శ్రీరాం )</name><uri>http://www.blogger.com/profile/00971680137941932814</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGTlINONrq0VczLe2nPfmnrOEp3kK1D880NQXzT0hz59E7WS8_-7ly0v4zUNy2OFEuE7TfreKF1GWOKDQNm5yMPgo4U2PYutO8ALaZX8vd5nD7HjzNRiUurQZsK5KOX8/s220/Photo0007.jpg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7840352491082926975.post-5348502514032847938</id><published>2009-02-26T21:01:00.000-08:00</published><updated>2009-02-26T21:09:24.691-08:00</updated><title type='text'>Write a C++ program that uses functions to swap two characters.</title><content type='html'>#include(iostream.h) // place this &#39;&lt;&#39; &amp;amp; &#39;&gt;&#39; instead of &#39;(&#39; &amp;amp; &#39;)&#39; before iostream.h&lt;br /&gt;#include(conio.h)&lt;br /&gt;void swap(int, int);&lt;br /&gt;void main( )&lt;br /&gt;{&lt;br /&gt; char s1, s2;&lt;br /&gt; clrscr( );&lt;br /&gt; cout&lt;&lt;&quot;Enter the two characters to swap:&quot;;&lt;br /&gt; cin&gt;&gt;s1&gt;&gt;s2;&lt;br /&gt; swap(s1, s2);&lt;br /&gt; getch( );&lt;br /&gt;}&lt;br /&gt;void swap(char c1, char c2)&lt;br /&gt;{&lt;br /&gt; char c3;&lt;br /&gt; cout&lt;&lt;&quot;Characters before swapping:&quot;&lt;&lt; c1&lt;&lt;&quot;and&quot;&lt;&lt; c2;&lt;br /&gt; c3=c1;&lt;br /&gt; c1=c2;&lt;br /&gt; c2=c3;&lt;br /&gt; cout&lt;&lt;&quot;Characters after swapping:&quot;&lt;&lt; c1&lt;&lt;&quot;and&quot;&lt;&lt; c2;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Output: Enter the two characters to swap: a  b&lt;br /&gt;&lt;br /&gt;Values before swapping: a and b&lt;br /&gt;Values after swapping: b and a&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Note&lt;/span&gt;:- If u have any doubt regarding this program &lt;a style=&quot;background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;&quot; name=&quot;AdBriteInlineAd_program&quot; id=&quot;AdBriteInlineAd_program&quot; target=&quot;_top&quot;&gt;&lt;/a&gt; or logic, please feel free to contact me.</content><link rel='replies' type='application/atom+xml' href='http://cppprogramskills.blogspot.com/feeds/5348502514032847938/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-that-uses-functions-to_26.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/5348502514032847938'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/5348502514032847938'/><link rel='alternate' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-that-uses-functions-to_26.html' title='Write a C++ program that uses functions to swap two characters.'/><author><name>shriram ( శ్రీరాం )</name><uri>http://www.blogger.com/profile/00971680137941932814</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGTlINONrq0VczLe2nPfmnrOEp3kK1D880NQXzT0hz59E7WS8_-7ly0v4zUNy2OFEuE7TfreKF1GWOKDQNm5yMPgo4U2PYutO8ALaZX8vd5nD7HjzNRiUurQZsK5KOX8/s220/Photo0007.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7840352491082926975.post-5618411776718211744</id><published>2009-02-26T05:42:00.000-08:00</published><updated>2009-02-26T20:44:53.473-08:00</updated><title type='text'>Write a C++ program that uses functions to swap two integers.</title><content type='html'>#include(iostream.h) // place this &#39;&lt;&#39; &amp;amp; &#39;&gt;&#39; instead of &#39;(&#39; &amp;amp; &#39;)&#39; before iostream.h&lt;br /&gt;#include(conio.h)&lt;br /&gt;void swap(int, int);&lt;br /&gt;void main( )&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;int x, y;&lt;br /&gt;clrscr( );&lt;br /&gt;cout&lt;&lt;&quot;Enter the two numbers to swap:&quot;;  cin&gt;&gt;x &gt;&gt;y;&lt;br /&gt;swap(x, y);&lt;br /&gt;getch( );&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;void swap( int a, int b)&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;int temp;&lt;br /&gt;cout&lt;&lt;&quot;Values before swapping: &quot;&lt;&lt; a &lt;&lt;&quot;and&quot;&lt;&lt; b;&lt;br /&gt;temp=a; &lt;br /&gt;a=b; &lt;br /&gt;t=temp; &lt;br /&gt;cout&lt;&lt;&quot;Vaues after swapping:&quot; &lt;&lt; a &lt;&lt;&quot;and&quot;&lt;&lt; b;&lt;br /&gt; &lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;}&lt;/span&gt;  &lt;br /&gt;&lt;br /&gt;Output: Enter the two numbers to swap: 10 20 &lt;br /&gt;&lt;br /&gt;Values before swapping: 10 and 20&lt;br /&gt;Values after swapping: 20 and 10 &lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Note&lt;/span&gt;:- If u have any doubt regarding this program &lt;a style=&quot;background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;&quot; name=&quot;AdBriteInlineAd_program&quot; id=&quot;AdBriteInlineAd_program&quot; target=&quot;_top&quot;&gt;&lt;/a&gt; or logic, please feel free to contact me.</content><link rel='replies' type='application/atom+xml' href='http://cppprogramskills.blogspot.com/feeds/5618411776718211744/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-that-uses-functions-to.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/5618411776718211744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/5618411776718211744'/><link rel='alternate' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-that-uses-functions-to.html' title='Write a C++ program that uses functions to swap two integers.'/><author><name>shriram ( శ్రీరాం )</name><uri>http://www.blogger.com/profile/00971680137941932814</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGTlINONrq0VczLe2nPfmnrOEp3kK1D880NQXzT0hz59E7WS8_-7ly0v4zUNy2OFEuE7TfreKF1GWOKDQNm5yMPgo4U2PYutO8ALaZX8vd5nD7HjzNRiUurQZsK5KOX8/s220/Photo0007.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7840352491082926975.post-6925696308665358671</id><published>2009-02-26T05:33:00.000-08:00</published><updated>2009-02-26T21:00:19.875-08:00</updated><title type='text'>Write a C++ program that uses a recursive function for solving Towers of Hanoi problem.</title><content type='html'>#include(iostream.h) // place this &#39;&lt;&#39; &amp;amp; &#39;&gt;&#39; instead of &#39;(&#39; &amp;amp; &#39;)&#39; before iostream.h&lt;br /&gt;#include(conio.h)&lt;br /&gt;#include(math.h)&lt;br /&gt;void hanoi(int x, char from, char to, char aux)&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;if(x==1)&lt;br /&gt;cout&lt;&lt;&quot;Move Disk From&quot;&lt;&lt; from &lt;&lt;&quot;to&quot;&lt;&lt; to;&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;hanoi(x-1,from,aux,to);&lt;br /&gt;cout&lt;&lt;&quot;Move Disk From&quot;&lt;&lt; from &lt;&lt;&quot;to&quot;&lt;&lt; to;&lt;br /&gt;}&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;void main( )&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;int disk;&lt;br /&gt;int moves;&lt;br /&gt;clrscr();&lt;br /&gt;cout&lt;&lt;&quot;Enter the number of disks you want to play with:&quot;;&lt;br /&gt;cin&gt;&gt;disk;&lt;br /&gt;moves=pow(2,disk)-1;&lt;br /&gt;cout&lt;&lt;&quot;The No of moves required is:&quot; &lt;&lt; moves;&lt;br /&gt;hanoi(disk,&#39;A&#39;,&#39;C&#39;,&#39;B&#39;);&lt;br /&gt;getch( );&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Output&lt;/span&gt;:-&lt;br /&gt;Enter the number of disks you want to play with: 3&lt;br /&gt;&lt;br /&gt;The No of moves required is=7&lt;br /&gt;Move Disk from A to C&lt;br /&gt;Move Disk from A to B&lt;br /&gt;Move Disk from C to B&lt;br /&gt;Move Disk from A to C&lt;br /&gt;Move Disk from B to A&lt;br /&gt;Move Disk from B to C&lt;br /&gt;Move Disk from A to C&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Note&lt;/span&gt;:- If u have any doubt regarding this program &lt;a style=&quot;background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;&quot; name=&quot;AdBriteInlineAd_program&quot; id=&quot;AdBriteInlineAd_program&quot; target=&quot;_top&quot;&gt;&lt;/a&gt; or logic, please feel free to contact me.</content><link rel='replies' type='application/atom+xml' href='http://cppprogramskills.blogspot.com/feeds/6925696308665358671/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-that-uses-recursive.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/6925696308665358671'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/6925696308665358671'/><link rel='alternate' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-that-uses-recursive.html' title='Write a C++ program that uses a recursive function for solving Towers of Hanoi problem.'/><author><name>shriram ( శ్రీరాం )</name><uri>http://www.blogger.com/profile/00971680137941932814</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGTlINONrq0VczLe2nPfmnrOEp3kK1D880NQXzT0hz59E7WS8_-7ly0v4zUNy2OFEuE7TfreKF1GWOKDQNm5yMPgo4U2PYutO8ALaZX8vd5nD7HjzNRiUurQZsK5KOX8/s220/Photo0007.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7840352491082926975.post-2908203500364650841</id><published>2009-02-25T06:48:00.000-08:00</published><updated>2009-02-25T06:52:06.075-08:00</updated><title type='text'>Write C++ programs that use both recursive and non-recursive functions to find the GCD of two given integers.</title><content type='html'>a).&lt;span style=&quot;font-weight: bold;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;using Recursive function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;int gcd (int, int); //&lt;span style=&quot;font-weight: bold; color: rgb(0, 204, 204);&quot;&gt;func. declaration&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;.&lt;/span&gt;&lt;br /&gt;void main( )&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;int a, b, res;&lt;br /&gt;clrscr( );&lt;br /&gt;cout&lt;&lt;&quot;Enter the two integer values:&quot;;&lt;br /&gt;cin&gt;&gt; a &gt;&gt;b;&lt;br /&gt;res= gcd(a, b); // &lt;span style=&quot;font-weight: bold; color: rgb(102, 204, 204);&quot;&gt;calling function&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;.&lt;/span&gt;&lt;br /&gt;cout&lt;&lt;&quot; GCD is:&quot; &lt;&lt; res;&lt;br /&gt;getch( );&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;int gcd( int x, int y) //&lt;span style=&quot;font-weight: bold; color: rgb(102, 204, 204);&quot;&gt;called function&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;int z;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;&lt;/span&gt;z=x%y;&lt;br /&gt;if(z==0)&lt;br /&gt;return y;&lt;br /&gt;gcd(y,z); //&lt;span style=&quot;font-weight: bold; color: rgb(102, 204, 204);&quot;&gt;recursive function&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255); font-weight: bold;&quot;&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Note&lt;/span&gt;:- If u have any doubt regarding this program or logic, please feel free to contact me.</content><link rel='replies' type='application/atom+xml' href='http://cppprogramskills.blogspot.com/feeds/2908203500364650841/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-programs-that-use-both_5517.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/2908203500364650841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/2908203500364650841'/><link rel='alternate' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-programs-that-use-both_5517.html' title='Write C++ programs that use both recursive and non-recursive functions to find the GCD of two given integers.'/><author><name>shriram ( శ్రీరాం )</name><uri>http://www.blogger.com/profile/00971680137941932814</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGTlINONrq0VczLe2nPfmnrOEp3kK1D880NQXzT0hz59E7WS8_-7ly0v4zUNy2OFEuE7TfreKF1GWOKDQNm5yMPgo4U2PYutO8ALaZX8vd5nD7HjzNRiUurQZsK5KOX8/s220/Photo0007.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7840352491082926975.post-3873744548426079020</id><published>2009-02-25T06:43:00.000-08:00</published><updated>2009-02-25T06:47:18.246-08:00</updated><title type='text'>Write C++ programs that use both recursive and non-recursive functions to find the GCD of two given integers.</title><content type='html'>a). &lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;Without using Recursive function&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;void gcd (int, int); //&lt;span style=&quot;font-weight: bold;&quot;&gt;func. declaration&lt;/span&gt;.&lt;br /&gt;void main( )&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;int a, b;&lt;br /&gt;clrscr( );&lt;br /&gt;cout&lt;&lt;&quot;Enter the two integer values:&quot;;&lt;br /&gt;cin&gt;&gt;a &gt;&gt;b;&lt;br /&gt;cout&lt;&lt;&quot;Given numbers are:&quot; &lt;&lt; a &lt;&lt;&quot;and&quot; &lt;&lt; b;&lt;br /&gt;gcd(a, b); // &lt;span style=&quot;font-weight: bold;&quot;&gt;calling function&lt;/span&gt;.&lt;br /&gt;getch( );&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;void gcd( int x, int y) //&lt;span style=&quot;font-weight: bold;&quot;&gt;called function&lt;/span&gt;.&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;int z;&lt;br /&gt;for( ; ; ) //This is empty for loop.&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;z= x%y;&lt;br /&gt;if( z==0) break;&lt;br /&gt;x=y;&lt;br /&gt;y=z;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;cout&lt;&lt;&quot;The GCD is:&quot; &lt;&lt; y;&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255); font-weight: bold;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Note&lt;/span&gt;:- Take the values as 23 and 3 , then GCd is 3.&lt;br /&gt;This logic works, when a&gt;b. (ie., 23&gt;3 )&lt;br /&gt;I&#39;m not mentioned the logic when b&gt;a. ( for that, we need if-else statement)&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Explanation&lt;/span&gt;:-&lt;br /&gt;Here i&#39;m taking empty for loop becoz i dont have initial value , condition and increment or decrement.&lt;br /&gt;This for loop will ends, when &#39;z&#39; becomes zero. ie.,(z==0)</content><link rel='replies' type='application/atom+xml' href='http://cppprogramskills.blogspot.com/feeds/3873744548426079020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-programs-that-use-both_25.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/3873744548426079020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/3873744548426079020'/><link rel='alternate' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-programs-that-use-both_25.html' title='Write C++ programs that use both recursive and non-recursive functions to find the GCD of two given integers.'/><author><name>shriram ( శ్రీరాం )</name><uri>http://www.blogger.com/profile/00971680137941932814</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGTlINONrq0VczLe2nPfmnrOEp3kK1D880NQXzT0hz59E7WS8_-7ly0v4zUNy2OFEuE7TfreKF1GWOKDQNm5yMPgo4U2PYutO8ALaZX8vd5nD7HjzNRiUurQZsK5KOX8/s220/Photo0007.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7840352491082926975.post-6821184076208166813</id><published>2009-02-25T06:27:00.000-08:00</published><updated>2009-02-26T20:48:36.660-08:00</updated><title type='text'>Write C++ programs that use both recursive and non-recursive functions to find the factorial of a given integer.</title><content type='html'>int fact( int); // function declaration&lt;br /&gt;void main( )&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 102, 255);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;int no,result;&lt;br /&gt;clrscr( );&lt;br /&gt;cout&lt;&lt;&quot;Enter the required number:&quot;; cin&gt;&gt;no;&lt;br /&gt;result = fact( no);&lt;br /&gt;cout&lt;&lt;&quot;Factorial is :&quot; &lt;&lt; result;&lt;br /&gt;getch( );&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;int fact(int n)&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 102, 0); font-weight: bold;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;int ft;&lt;br /&gt;for( ft=1; n&gt;=1; n--)&lt;br /&gt;ft=ft*n;&lt;br /&gt;return ft;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Output&lt;/span&gt;:-  4 Factorial is : 24&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;&lt;span style=&quot;color: rgb(255, 102, 102);&quot;&gt;(a)&lt;/span&gt;.using recursive function&lt;/span&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;int fact( int); // function declaration&lt;br /&gt;void main( )&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 102, 255);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;int no,result;&lt;br /&gt;clrscr( );&lt;br /&gt;cout&lt;&lt;&quot;Enter the required number:&quot;; cin&gt;&gt; n0;&lt;br /&gt;result = fact( no);&lt;br /&gt;cout&lt;&lt;&quot;Factorial :&quot;&lt;&lt; result;&lt;br /&gt;getch( );&lt;br /&gt;}&lt;br /&gt;int fact(int n)&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 102, 0); font-weight: bold;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;int ft;&lt;br /&gt;if( n==1)&lt;br /&gt;return 1;&lt;br /&gt;else&lt;br /&gt;ft= n*fact (n-1);&lt;br /&gt;return ft;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 102, 0);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Output&lt;/span&gt;:-  4 Factorial is : 24</content><link rel='replies' type='application/atom+xml' href='http://cppprogramskills.blogspot.com/feeds/6821184076208166813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-programs-that-use-both.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/6821184076208166813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/6821184076208166813'/><link rel='alternate' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-programs-that-use-both.html' title='Write C++ programs that use both recursive and non-recursive functions to find the factorial of a given integer.'/><author><name>shriram ( శ్రీరాం )</name><uri>http://www.blogger.com/profile/00971680137941932814</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGTlINONrq0VczLe2nPfmnrOEp3kK1D880NQXzT0hz59E7WS8_-7ly0v4zUNy2OFEuE7TfreKF1GWOKDQNm5yMPgo4U2PYutO8ALaZX8vd5nD7HjzNRiUurQZsK5KOX8/s220/Photo0007.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7840352491082926975.post-7679640448039296310</id><published>2009-02-25T06:12:00.000-08:00</published><updated>2009-02-25T06:20:32.109-08:00</updated><title type='text'>Write a C++ program to generate all the prime numbers between 1 to n, where n is a value supplied by the user.</title><content type='html'>#include(iostream.h) // place this &#39;&lt;&#39; &amp;amp; &#39;&gt;&#39; instead of &#39;(&#39; &amp;amp; &#39;)&#39; before iostream.h&lt;br /&gt;#include(conio.h)&lt;br /&gt;void main( )&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;int n, x, flag,ct;&lt;br /&gt;clrscr( );&lt;br /&gt;cout&lt;&lt;&quot;Enter the n value:&quot;;  cin&gt;&gt; n;&lt;br /&gt;cout&lt;&lt;&quot;Prime Numbers:&quot;;&lt;br /&gt;for( ct=1; ct&lt;=n; ct++)&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;x=2; flag=0;&lt;br /&gt;while(x&lt;=ct/2)&lt;br /&gt;{&lt;br /&gt;if(ct%x==0) { flag=1; break; }&lt;br /&gt;x++;&lt;br /&gt;}&lt;br /&gt;if(flag==0)&lt;br /&gt;cout&lt;&lt; ct;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;getch( );&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note:- If u have any doubt regarding this program or logic, please feel free to contact me.</content><link rel='replies' type='application/atom+xml' href='http://cppprogramskills.blogspot.com/feeds/7679640448039296310/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-to-generate-all-prime.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/7679640448039296310'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/7679640448039296310'/><link rel='alternate' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-to-generate-all-prime.html' title='Write a C++ program to generate all the prime numbers between 1 to n, where n is a value supplied by the user.'/><author><name>shriram ( శ్రీరాం )</name><uri>http://www.blogger.com/profile/00971680137941932814</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGTlINONrq0VczLe2nPfmnrOEp3kK1D880NQXzT0hz59E7WS8_-7ly0v4zUNy2OFEuE7TfreKF1GWOKDQNm5yMPgo4U2PYutO8ALaZX8vd5nD7HjzNRiUurQZsK5KOX8/s220/Photo0007.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7840352491082926975.post-5822340664303741874</id><published>2009-02-24T20:47:00.000-08:00</published><updated>2009-02-25T06:04:49.322-08:00</updated><title type='text'>Write a C++ program to generate the first n terms of the sequence.</title><content type='html'>--A fibonacci sequence is difined as follows: the first and second term in the sequence are 0 and 1. Subsequent terms are found by adding the proceeding two terms  in the sequence.&lt;br /&gt;&lt;br /&gt;#include(iostream.h)&lt;br /&gt;#include(conio.h)&lt;br /&gt;void main( )&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(51, 51, 255);&quot;&gt;{&lt;/span&gt;&lt;br /&gt;int f=0, s=1, t, n, ct;&lt;br /&gt;clrscr( );&lt;br /&gt;cout&lt;&lt;&quot;Enter the no. of terms:&quot;;&lt;br /&gt;cin&gt;&gt;n;&lt;br /&gt;cout&lt;&lt;&quot;Fibonacci series:&quot;;&lt;br /&gt;cout&lt;&lt; f &lt;&lt; s;&lt;br /&gt;for( ct=3; ct&lt;=10; ct++)&lt;br /&gt;{ &lt;br /&gt;t=f+s;&lt;br /&gt;cout&lt;&lt; t;&lt;br /&gt;f=s;&lt;br /&gt;s=t;&lt;br /&gt;}&lt;br /&gt;getch( );&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 255); font-weight: bold;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here &#39;f&#39; means &#39;first&#39; &lt;strong style=&quot;font-weight: normal;&quot;&gt;&#39;s&#39; means &#39;second&#39;&lt;/strong&gt;&lt;br /&gt;&lt;strong style=&quot;font-weight: normal;&quot;&gt;&#39;t&#39; means &#39;third&#39;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&#39;ct&#39; means &#39;count&#39; the displayed numbers.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Output&lt;/span&gt;:- Enter the no. of terms: 10&lt;br /&gt;&lt;br /&gt;The Fibonocci series:&lt;br /&gt;0 1 1 2 3 5 8 13 21  34&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Note&lt;/span&gt;:- If u have any doubt regarding this program or logic, please feel free to contact me.</content><link rel='replies' type='application/atom+xml' href='http://cppprogramskills.blogspot.com/feeds/5822340664303741874/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-to-generate-first-n.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/5822340664303741874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/5822340664303741874'/><link rel='alternate' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-to-generate-first-n.html' title='Write a C++ program to generate the first n terms of the sequence.'/><author><name>shriram ( శ్రీరాం )</name><uri>http://www.blogger.com/profile/00971680137941932814</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGTlINONrq0VczLe2nPfmnrOEp3kK1D880NQXzT0hz59E7WS8_-7ly0v4zUNy2OFEuE7TfreKF1GWOKDQNm5yMPgo4U2PYutO8ALaZX8vd5nD7HjzNRiUurQZsK5KOX8/s220/Photo0007.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7840352491082926975.post-2335898255669731785</id><published>2009-02-24T05:57:00.000-08:00</published><updated>2009-02-24T06:14:47.174-08:00</updated><title type='text'>Write a C++ program to find the sum of individual digits of a positive integer.</title><content type='html'>#include(iostream.h) // place this &#39;&lt;&#39; &amp;amp; &#39;&gt;&#39; instead of &#39;(&#39; &amp;amp; &#39;)&#39; before iostream.h&lt;br /&gt;#include(conio.h)&lt;br /&gt;void main(void)&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;{&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;int no, rem, sum=0;&lt;br /&gt;clrscr();&lt;br /&gt;cout&lt;&lt;&quot;Enter the required number:&quot;;&lt;br /&gt;cin&gt;&gt;no;&lt;br /&gt;while(no&gt;0)&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 204, 0);&quot;&gt;&lt;strong&gt;{&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;rem=no%10;&lt;br /&gt;sum=sum+rem;&lt;br /&gt;no=no/10;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(51, 255, 51);&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;/strong&gt;cout&lt;&lt;&quot;Sum of individual digits of a positive integer is:&quot;&lt;&lt; sum;&lt;br /&gt;getch();&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(51, 51, 255);&quot;&gt;}&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Output:-&lt;br /&gt;here &#39;rem&#39; means remainder&lt;br /&gt;&lt;br /&gt;Enter the required number: 123&lt;br /&gt;Sum of individual digits of a positive integer is: 6&lt;br /&gt;&lt;br /&gt;Note:-If u have any doubt regarding this program &lt;a style=&quot;background: transparent url(http://files.adbrite.com/mb/images/green-double-underline-006600.gif) repeat-x scroll center bottom; cursor: pointer; color: rgb(0, 102, 0); text-decoration: none; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-bottom: -2px; padding-bottom: 2px;&quot; name=&quot;AdBriteInlineAd_program&quot; id=&quot;AdBriteInlineAd_program&quot; target=&quot;_top&quot;&gt;&lt;/a&gt;or logic, please feel free to contact me.</content><link rel='replies' type='application/atom+xml' href='http://cppprogramskills.blogspot.com/feeds/2335898255669731785/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-to-find-sum-of.html#comment-form' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/2335898255669731785'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7840352491082926975/posts/default/2335898255669731785'/><link rel='alternate' type='text/html' href='http://cppprogramskills.blogspot.com/2009/02/write-c-program-to-find-sum-of.html' title='Write a C++ program to find the sum of individual digits of a positive integer.'/><author><name>shriram ( శ్రీరాం )</name><uri>http://www.blogger.com/profile/00971680137941932814</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEGTlINONrq0VczLe2nPfmnrOEp3kK1D880NQXzT0hz59E7WS8_-7ly0v4zUNy2OFEuE7TfreKF1GWOKDQNm5yMPgo4U2PYutO8ALaZX8vd5nD7HjzNRiUurQZsK5KOX8/s220/Photo0007.jpg'/></author><thr:total>12</thr:total></entry></feed>