<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="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" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-7376754541559761952</atom:id><lastBuildDate>Thu, 07 Aug 2025 08:09:38 +0000</lastBuildDate><category>swapping</category><category>prime number</category><category>recursion</category><category>factorial</category><category>sort</category><category>call by reference</category><category>call by value</category><category>compiler</category><category>goto</category><category>print</category><category>return</category><title>C C++ programs</title><description>This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.</description><link>http://program-in-c.blogspot.com/</link><managingEditor>noreply@blogger.com (akshay)</managingEditor><generator>Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7376754541559761952.post-275741850766885666</guid><pubDate>Fri, 18 Nov 2011 12:59:00 +0000</pubDate><atom:updated>2011-11-18T04:59:19.614-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">sort</category><category domain="http://www.blogger.com/atom/ns#">swapping</category><title>c program bubble sort</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;b&gt;c program to implement bubble sort.&lt;/b&gt; Sorting refers to the operation of rearranging the element.&amp;nbsp;Bubble sort algorithm requires &lt;b&gt;n-1 passes, where n is the number of input&lt;/b&gt; items. Here is the c program&amp;nbsp;for bubble sort. The &lt;b&gt;bubble sort&lt;/b&gt; gets its name because elements tend to move up into the correct order like &lt;b&gt;bubbles rising to the surface.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
&lt;/code&gt;&lt;div style=&quot;overflow-x: scroll; overflow-y: scroll; padding-bottom: 10px; width: 550px;&quot;&gt;&lt;code&gt;
#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

int main( )
{
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int a[100];
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int i, j, temp, n ;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;how many numbers you want to sort : \n&quot;);
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;n);
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;Enter %d number values you want to sort\n&quot;, n);
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(j=0; j&amp;lt;n; j++)
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;a[j]);
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(j=1;j&amp;lt;n;j++)
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0; i&amp;lt;n; i++)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(a[i]&amp;gt;a[i+1])
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; temp=a[i];
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a[i]=a[i+1];
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a[i+1]=temp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&amp;nbsp; &amp;nbsp; &amp;nbsp;printf ( &quot;\n\nArray after sorting:\n&quot;) ;
&amp;nbsp; &amp;nbsp; &amp;nbsp;for ( i = 0 ; i &amp;lt;n ; i++ )
&amp;nbsp; &amp;nbsp; &amp;nbsp;printf ( &quot;%d\t&quot;, a[i] ) ;
&amp;nbsp; &amp;nbsp; &amp;nbsp;getch();
}

&lt;/code&gt;






&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;output:&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZYtRfrllt6f1XknhqvDVNxvRnC8YKrb6bZNUweNXYz7zALr2WfQUwXL02oEj4CMGg6WnViwwFEVBzaN-8jCjgGwlJE0rJcw1JhjkiGu_jp6M7hyphenhyphen8TVm4VRu39G4z4BkQLty194rV4inFa/s1600/c+program+bubble+sort.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;c program bubble sort output&quot; border=&quot;0&quot; height=&quot;205&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZYtRfrllt6f1XknhqvDVNxvRnC8YKrb6bZNUweNXYz7zALr2WfQUwXL02oEj4CMGg6WnViwwFEVBzaN-8jCjgGwlJE0rJcw1JhjkiGu_jp6M7hyphenhyphen8TVm4VRu39G4z4BkQLty194rV4inFa/s320/c+program+bubble+sort.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;c program to implement bubble sort&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: #0b5394;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: #0b5394;&quot;&gt;&lt;b&gt;Use of Bubble sort :&lt;/b&gt;Bubble sort is simple and so it is often used to introduce the concept of sorting algorithm, to introductory&amp;nbsp;computer science students.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.&lt;/div&gt;</description><link>http://program-in-c.blogspot.com/2011/11/c-program-bubble-sort.html</link><author>noreply@blogger.com (akshay)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZYtRfrllt6f1XknhqvDVNxvRnC8YKrb6bZNUweNXYz7zALr2WfQUwXL02oEj4CMGg6WnViwwFEVBzaN-8jCjgGwlJE0rJcw1JhjkiGu_jp6M7hyphenhyphen8TVm4VRu39G4z4BkQLty194rV4inFa/s72-c/c+program+bubble+sort.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7376754541559761952.post-2237625899592599033</guid><pubDate>Fri, 18 Nov 2011 11:54:00 +0000</pubDate><atom:updated>2011-11-18T03:58:52.281-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">compiler</category><title>c program to implement dfa</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;b&gt;C program of dfa implementation&lt;/b&gt;. Let us first know what is &lt;b&gt;&lt;u&gt;DFA&lt;/u&gt;&lt;/b&gt; or let us again revise the concept of DFA? Automation are basically language acceptor or language&lt;br /&gt;
recognizer. A&lt;i&gt; finite automata&lt;/i&gt; is a collection of 5-tuple(Q,∑,∂,q0,F). Where&lt;br /&gt;
Q=finite set of states&lt;br /&gt;
∑=input symbol&lt;br /&gt;
∂=transition function&lt;br /&gt;
q0=initial state&lt;br /&gt;
F=set of final state&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is the &lt;b&gt;&lt;u&gt;c program to implement dfa&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;div style=&quot;overflow-x: scroll; overflow-y: scroll; padding-bottom: 10px; width: 550px;&quot;&gt;&lt;code&gt;

#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

int ninputs;

int check(char,int );          //function declaration
int dfa[10][10];
char c[10],&amp;nbsp;string[10];
int main()
{
&amp;nbsp; &amp;nbsp; int nstates, nfinals;
&amp;nbsp; &amp;nbsp; int f[10];
&amp;nbsp; &amp;nbsp; int i,j,s=0,final=0;
&amp;nbsp; &amp;nbsp; printf(&quot;enter the number of states that your dfa consist of \n&quot;);
&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;nstates);
&amp;nbsp; &amp;nbsp; printf(&quot;enter the number of input symbol that dfa have \n&quot;);
&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;ninputs);
&amp;nbsp; &amp;nbsp; printf(&quot;\nenter input symbols\t&quot;);
&amp;nbsp; &amp;nbsp; for(i=0; i&amp;lt;ninputs; i++)
&amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\n\n %d input\t&quot;, i+1);
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;%c&quot;,c[i]=getch());
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; printf(&quot;\n\nenter number of final states\t&quot;);
&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;nfinals);
&amp;nbsp; 
&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;nfinals;i++)
&amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\n\nFinal state %d : q&quot;,i+1);
&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;f[i]);
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; 
&amp;nbsp; &amp;nbsp; 
&amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;-----------------------------------------------------------------------&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\n\ndefine transition rule as (initial state, input symbol ) = final state\n&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp;for(i=0; i&amp;lt;ninputs; i++)
&amp;nbsp; &amp;nbsp; &amp;nbsp;{
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(j=0; j&amp;lt;nstates; j++)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\n(q%d , %c ) = q&quot;,j,c[i]);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;dfa[i][j]);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&amp;nbsp; &amp;nbsp; 
&amp;nbsp; &amp;nbsp; &amp;nbsp;do
&amp;nbsp; &amp;nbsp; &amp;nbsp;{
&amp;nbsp; &amp;nbsp; &amp;nbsp;i=0;
&amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\n\nEnter Input String.. &quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp;scanf(&quot;%s&quot;,string);
&amp;nbsp; 
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; while(string[i]!=&#39;\0&#39;)
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; if((s=check(string[i++],s))&amp;lt;0)
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; break;
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; for(i=0 ;i&amp;lt;nfinals ;i++)
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; if(f[i] ==s )
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; final=1;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(final==1)
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; printf(&quot;\n valid string&quot;);
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; else
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; printf(&quot;invalid string&quot;);
&amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; getch();
&amp;nbsp; 
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; printf(&quot;\nDo you want to continue.? &amp;nbsp;\n(y/n) &quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&amp;nbsp; &amp;nbsp; &amp;nbsp;while(getch()==&#39;y&#39;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; 
&amp;nbsp; &amp;nbsp; getch();
}

int check(char b,int d)
{
&amp;nbsp; &amp;nbsp; int j;
&amp;nbsp; &amp;nbsp; for(j=0; j&amp;lt;ninputs; j++)
&amp;nbsp; &amp;nbsp; if(b==c[j])
&amp;nbsp; &amp;nbsp; return(dfa[d][j]);
&amp;nbsp; &amp;nbsp; return -1; &amp;nbsp; 
}

&lt;/code&gt;
&lt;/div&gt;&lt;/pre&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp;output :&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6hKJZ3axbNAWcnf7KPKRk29aP6JqwXLtupTOAuiQOBnaSSqD2S47AgfGRr2uG69m_AkqHiYSRKIKPbTd8zmxPNTvVQf1kZvxIyaE00-imE2JAEpqFn0z0UjIzTf5yPJIFTJ_dHB9YHErL/s1600/c+program+to+implement+dfa.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;218&quot; alt=&quot;c program to implement dfa&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6hKJZ3axbNAWcnf7KPKRk29aP6JqwXLtupTOAuiQOBnaSSqD2S47AgfGRr2uG69m_AkqHiYSRKIKPbTd8zmxPNTvVQf1kZvxIyaE00-imE2JAEpqFn0z0UjIzTf5yPJIFTJ_dHB9YHErL/s320/c+program+to+implement+dfa.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;c program to implement dfa&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&amp;nbsp;The above output is for the dfa to check whether the given binary number is even.&lt;br /&gt;
Its DFA is made as follows :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxu5wdBPGeTSWEWimKyzciuBxJwWSp58ufhtSEgQwdAW5tUKYCTVzn4Mzdc6EEm-QNVqvGvUdHidUavLh_LS23SawUJmQAONNxlNLGJp1k6HI3Ri8oUcutRoc31R_jnCIIiAYVaJM6afgW/s1600/c+program+to+implement+dfa+1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;149&quot; alt=&quot;c program to implement dfa&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxu5wdBPGeTSWEWimKyzciuBxJwWSp58ufhtSEgQwdAW5tUKYCTVzn4Mzdc6EEm-QNVqvGvUdHidUavLh_LS23SawUJmQAONNxlNLGJp1k6HI3Ri8oUcutRoc31R_jnCIIiAYVaJM6afgW/s320/c+program+to+implement+dfa+1.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;DFA: To check whether the given number is even&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;and its table is made as :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;MsoTableGrid&quot; style=&quot;border-collapse: collapse; border: none; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;&quot;&gt;&lt;tbody&gt;
&lt;tr style=&quot;height: 17.9pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;&quot;&gt;&lt;td style=&quot;border: solid black 1.0pt; height: 17.9pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 53.75pt;&quot; valign=&quot;top&quot; width=&quot;72&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;States-Input&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-left: none; border: solid black 1.0pt; height: 17.9pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 53.75pt;&quot; valign=&quot;top&quot; width=&quot;72&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-left: none; border: solid black 1.0pt; height: 17.9pt; mso-border-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-themecolor: text1; mso-border-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 53.75pt;&quot; valign=&quot;top&quot; width=&quot;72&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 17.9pt; mso-yfti-irow: 1;&quot;&gt;   &lt;td style=&quot;border-top: none; border: solid black 1.0pt; height: 17.9pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 53.75pt;&quot; valign=&quot;top&quot; width=&quot;72&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;q0&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; height: 17.9pt; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 53.75pt;&quot; valign=&quot;top&quot; width=&quot;72&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;q2&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; height: 17.9pt; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 53.75pt;&quot; valign=&quot;top&quot; width=&quot;72&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;q1&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 17.9pt; mso-yfti-irow: 2;&quot;&gt;   &lt;td style=&quot;border-top: none; border: solid black 1.0pt; height: 17.9pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 53.75pt;&quot; valign=&quot;top&quot; width=&quot;72&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;q1&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; height: 17.9pt; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 53.75pt;&quot; valign=&quot;top&quot; width=&quot;72&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;q2&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; height: 17.9pt; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 53.75pt;&quot; valign=&quot;top&quot; width=&quot;72&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;q1&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr style=&quot;height: 18.9pt; mso-yfti-irow: 3; mso-yfti-lastrow: yes;&quot;&gt;   &lt;td style=&quot;border-top: none; border: solid black 1.0pt; height: 18.9pt; mso-border-alt: solid black .5pt; mso-border-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 53.75pt;&quot; valign=&quot;top&quot; width=&quot;72&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;q2&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; height: 18.9pt; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 53.75pt;&quot; valign=&quot;top&quot; width=&quot;72&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;q2&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;   &lt;td style=&quot;border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; height: 18.9pt; mso-border-alt: solid black .5pt; mso-border-bottom-themecolor: text1; mso-border-left-alt: solid black .5pt; mso-border-left-themecolor: text1; mso-border-right-themecolor: text1; mso-border-themecolor: text1; mso-border-top-alt: solid black .5pt; mso-border-top-themecolor: text1; padding: 0in 5.4pt 0in 5.4pt; width: 53.75pt;&quot; valign=&quot;top&quot; width=&quot;72&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: 0.0001pt;&quot;&gt;q1&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: #0b5394;&quot;&gt;&lt;b&gt;Uses of DFA&lt;/b&gt;: &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: #3d85c6;&quot;&gt;&amp;nbsp;The very good example of finite state system is a control mechanism of elevator. It is very good tool for the programs such as text editors and lexical analyzer.&lt;/span&gt;&lt;br /&gt;
Thanks.&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.&lt;/div&gt;</description><link>http://program-in-c.blogspot.com/2011/11/c-program-to-implement-dfa.html</link><author>noreply@blogger.com (akshay)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6hKJZ3axbNAWcnf7KPKRk29aP6JqwXLtupTOAuiQOBnaSSqD2S47AgfGRr2uG69m_AkqHiYSRKIKPbTd8zmxPNTvVQf1kZvxIyaE00-imE2JAEpqFn0z0UjIzTf5yPJIFTJ_dHB9YHErL/s72-c/c+program+to+implement+dfa.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7376754541559761952.post-7080986487311223536</guid><pubDate>Wed, 02 Nov 2011 20:53:00 +0000</pubDate><atom:updated>2011-11-16T17:09:56.330-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">factorial</category><category domain="http://www.blogger.com/atom/ns#">recursion</category><title>C program to find factorial of a number using recursion</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
Factorial is mostly used in calculting permutation and combination. Factorial sign is &#39;!&#39; i.e exclamatory mark.&lt;br /&gt;
For eg 4! can be calculated as : 4!=4*3*2*1=24. Here the c program to calculate factorial using recursion function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
&lt;div style=&quot;overflow-x: scroll; overflow-y: scroll; padding-bottom: 10px; width: 550px;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

int recfact(int);

main( )
{
int a, fact, rec ;
printf ( &quot;\nEnter any number &quot; ) ;
scanf ( &quot;%d&quot;, &amp;amp;a ) ;
rec = recfact ( a ) ;
printf ( &quot;Factorial value = %d&quot;, fact ) ;
getch();
}
int recfact( int x )
{
int f ;
if ( x == 1 )
return ( 1 ) ;
else
f = x * recfact ( x - 1 ) ;
return ( f ) ;
}
&lt;/div&gt;&lt;/code&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Output :&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnuI1ff3mdzWIJV9q7vClI5lgUfbnogBYXZc7nxYGl_uWFjXovRHQL2-BnROEYaUGPjo-BBxioc40Ma5FQq72p0Sp1yqPPPvtvR1awB5BnYTd9OsfN2PkHfvf2KrvFlSf1b8pdH4s_pBde/s1600/c+program+to+find+factorial+of+given+number+using+factorial.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;C program to find factorial using recursion&quot; border=&quot;0&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnuI1ff3mdzWIJV9q7vClI5lgUfbnogBYXZc7nxYGl_uWFjXovRHQL2-BnROEYaUGPjo-BBxioc40Ma5FQq72p0Sp1yqPPPvtvR1awB5BnYTd9OsfN2PkHfvf2KrvFlSf1b8pdH4s_pBde/s320/c+program+to+find+factorial+of+given+number+using+factorial.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;c program to find factorial using recursion&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.&lt;/div&gt;</description><link>http://program-in-c.blogspot.com/2011/11/c-program-to-find-factorial-of-number.html</link><author>noreply@blogger.com (akshay)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnuI1ff3mdzWIJV9q7vClI5lgUfbnogBYXZc7nxYGl_uWFjXovRHQL2-BnROEYaUGPjo-BBxioc40Ma5FQq72p0Sp1yqPPPvtvR1awB5BnYTd9OsfN2PkHfvf2KrvFlSf1b8pdH4s_pBde/s72-c/c+program+to+find+factorial+of+given+number+using+factorial.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7376754541559761952.post-6226292904656759828</guid><pubDate>Wed, 02 Nov 2011 20:49:00 +0000</pubDate><atom:updated>2011-11-16T17:10:30.133-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">factorial</category><title>C program to find factorial of a number</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
&lt;div style=&quot;overflow-x: scroll; overflow-y: scroll; padding-bottom: 10px; width: 550px;&quot;&gt;C program to calculate factorial of a number :
For an integer n greater than or equal to 1, the factorial is the product of all integers less than
or equal to n but greater than or equal to 1. The factorial value of 0 is defined as equal to 1.
The factorial values for negative integers are not defined.
For eg : factorial of 5 i.e 5!=5*4*3*2*1=120.


#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

int fact(int );

int main( )
{
int a, f ;
printf ( &quot;\nEnter any number &quot; ) ;
scanf ( &quot;%d&quot;, &amp;amp;a ) ;
f = fact ( a ) ;
printf ( &quot;Factorial value = %d&quot;, f ) ;
getch();
}

int fact ( int x )
{
int f = 1, i ;
for ( i = x ; i &amp;gt;= 1 ; i-- )
f = f * i ;
return ( f ) ;
}
&lt;/div&gt;&lt;/code&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Output :&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfqm9Rih9k4STTO_Uu7vSJJI2iSfiiztYdkUdeDtX3z6D2p4VLvTi72WYi6ahPSeWYLw0KxXPwUbSYLS87IWkwnt3dpMhgZ8Tl8WSH48chv1ix0Hkc8ENIf1CU1tdPMimfx1oJThLvOuNc/s1600/c+program+to+find+factorial+of+given+number.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;187&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfqm9Rih9k4STTO_Uu7vSJJI2iSfiiztYdkUdeDtX3z6D2p4VLvTi72WYi6ahPSeWYLw0KxXPwUbSYLS87IWkwnt3dpMhgZ8Tl8WSH48chv1ix0Hkc8ENIf1CU1tdPMimfx1oJThLvOuNc/s320/c+program+to+find+factorial+of+given+number.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
C program to find factorial.&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.&lt;/div&gt;</description><link>http://program-in-c.blogspot.com/2011/11/c-program-to-find-factorial-of-number_02.html</link><author>noreply@blogger.com (akshay)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfqm9Rih9k4STTO_Uu7vSJJI2iSfiiztYdkUdeDtX3z6D2p4VLvTi72WYi6ahPSeWYLw0KxXPwUbSYLS87IWkwnt3dpMhgZ8Tl8WSH48chv1ix0Hkc8ENIf1CU1tdPMimfx1oJThLvOuNc/s72-c/c+program+to+find+factorial+of+given+number.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7376754541559761952.post-73133371885506913</guid><pubDate>Wed, 02 Nov 2011 20:38:00 +0000</pubDate><atom:updated>2011-11-17T02:51:01.342-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">return</category><title>c program return statement returns more than one value</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This program makes a contrasting concept that how a return statement&lt;br /&gt;
can return more than one value. Usually in C programming we make a call by value.&lt;br /&gt;
This means&amp;nbsp;that in general you cannot alter the actual arguments. But if&lt;br /&gt;
desired, it can always be achieved through a call by reference.&lt;br /&gt;
Using a &lt;b&gt;call by reference intelligently we can make a function&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;return more than one value at a time&lt;/b&gt;, which is not possible&lt;br /&gt;
ordinarily. This is shown in the program given below.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
&lt;div style=&quot;overflow-x: scroll; overflow-y: scroll; padding-bottom: 10px; width: 550px;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

int areaperi ( int r, float *a, float *p )
{
*a = 3.14 * r * r ;
*p = 2 * 3.14 * r ;
return (0);
}

int main( )
{
int radius ;
float area, perimeter ;
printf ( &quot;\nEnter radius of a circle &quot; ) ;
scanf ( &quot;%d&quot;, &amp;amp;radius ) ;
areaperi ( radius, &amp;amp;area, &amp;amp;perimeter ) ;
printf ( &quot;Area = %f&quot;, area ) ;
printf ( &quot;\nPerimeter = %f&quot;, perimeter ) ;
getch();
}

&lt;/div&gt;&lt;/code&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Output &lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3o0v5m6vz0YysWj__k02Rf1DSvBEHUbqDZLNxp34wkiBwFSlnZiKMsCKnFaCXXM3rj44lB1KapmC1hVNM0lVXrjdprXt09fGgncCQ1mlGbEpVSHrT5-UqgBwMbR4UqT8KNp4pb9R48-nz/s1600/c+program+to+return+more+than+two+variables.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;C program to return more than one value&quot; border=&quot;0&quot; height=&quot;187&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3o0v5m6vz0YysWj__k02Rf1DSvBEHUbqDZLNxp34wkiBwFSlnZiKMsCKnFaCXXM3rj44lB1KapmC1hVNM0lVXrjdprXt09fGgncCQ1mlGbEpVSHrT5-UqgBwMbR4UqT8KNp4pb9R48-nz/s320/c+program+to+return+more+than+two+variables.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;C porgram to return more than one value.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.&lt;/div&gt;</description><link>http://program-in-c.blogspot.com/2011/11/how-in-c-program-return-statement.html</link><author>noreply@blogger.com (akshay)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3o0v5m6vz0YysWj__k02Rf1DSvBEHUbqDZLNxp34wkiBwFSlnZiKMsCKnFaCXXM3rj44lB1KapmC1hVNM0lVXrjdprXt09fGgncCQ1mlGbEpVSHrT5-UqgBwMbR4UqT8KNp4pb9R48-nz/s72-c/c+program+to+return+more+than+two+variables.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7376754541559761952.post-159850016479231936</guid><pubDate>Tue, 01 Nov 2011 20:09:00 +0000</pubDate><atom:updated>2011-11-17T02:50:19.537-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">sort</category><title>c program to implement Heap sort Algorithm</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;i&gt;&lt;b&gt;Before going through this program. Read this for better understanding of program.“Consider the complete tree H. Observe that H is a heap. H is represented in array TREE.&amp;nbsp;That is, TREE[1] is the root of the tree H, and the left and right children of node TREE[k] are,&amp;nbsp;respectively, TREE[2k] and TREE[2k+1]. This means that in particular, that the parent of any non root&amp;nbsp;node TREE[j] is the node TREE[j/2](where j/2 means integer division). Observe that the nodes of H on&amp;nbsp;the same level appear one after the other in the array TREE”.&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Write a program to apply heap sort algorithm ?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
&lt;/code&gt;&lt;div style=&quot;overflow-x: scroll; overflow-y: scroll; padding-bottom: 10px; width: 550px;&quot;&gt;&lt;code&gt;#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

int main()
{
&amp;nbsp; &amp;nbsp; &amp;nbsp; int TREE[10],N,i,j,K,p,c,temp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n\n Enter no of elements..&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;N);
&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n\n Enter the nos..&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=1;i&amp;lt;=N;i++)
&amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;TREE[i]);
&amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=2;i&amp;lt;=N;i++)
&amp;nbsp; &amp;nbsp; &amp;nbsp; {
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; K=i;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; do
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; {
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(TREE[K]&amp;gt;TREE[K/2]) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Values are inserted in the heap
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; temp=TREE[K];
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;TREE[K]=TREE[K/2];
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;TREE[K/2]=temp;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p=K/2;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; K=p;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;}
&amp;nbsp; &amp;nbsp; &amp;nbsp; while(K!=0);
&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n\n\n On inserting values are arranged as \n&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=1;i&amp;lt;=N;i++) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Displaying values in heap
&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d\t&quot;,TREE[i]);
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; for(j=N;j&amp;gt;0;j--)
&amp;nbsp; &amp;nbsp; &amp;nbsp; {
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;temp=TREE[1];
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;TREE[1]=TREE[j];
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;TREE[j]=temp;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;p=0;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;do
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; { &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Heap sorting is applied
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;c=2*p+2;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;if((TREE[c]&amp;lt;TREE[c+1]) &amp;amp;&amp;amp; c&amp;lt;j-1)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c++;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;if(TREE[p]&amp;lt;TREE[c] &amp;amp;&amp;amp; c&amp;lt;j)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;temp=TREE[p];
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TREE[p]=TREE[c];
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TREE[c]=temp;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;}
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;p=c;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;}while(c&amp;lt;(j+1));
&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n\n\n The sorted nos are..&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=1;i&amp;lt;=N;i++) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // printing the heap in sorted order
&amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d\t&quot;,TREE[i]);
&amp;nbsp; &amp;nbsp; &amp;nbsp; getch();
}
&lt;/code&gt;



&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/pre&gt;Output :&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiz9UJ_LHX1gUcwCY_dnH1bgT65GpKs6QYErwpe4GUAhSLGCV4fSY1Mtm1fPGzUQ44_iqTN4sf1aZ8UY86g7uIyDcZNpm3EW5jL2IhtJpAzEuCbJqBd_yZvB2xe5Q8YhyQt6XFUYQVWScEX/s1600/C+program+to+write+heap+sort+output.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;C program to implement heap sort, heap sorting&quot; border=&quot;0&quot; height=&quot;148&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiz9UJ_LHX1gUcwCY_dnH1bgT65GpKs6QYErwpe4GUAhSLGCV4fSY1Mtm1fPGzUQ44_iqTN4sf1aZ8UY86g7uIyDcZNpm3EW5jL2IhtJpAzEuCbJqBd_yZvB2xe5Q8YhyQt6XFUYQVWScEX/s320/C+program+to+write+heap+sort+output.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Output : C program for Heap sort&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.&lt;/div&gt;</description><link>http://program-in-c.blogspot.com/2011/11/write-c-program-to-implement-heap-sort.html</link><author>noreply@blogger.com (akshay)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiz9UJ_LHX1gUcwCY_dnH1bgT65GpKs6QYErwpe4GUAhSLGCV4fSY1Mtm1fPGzUQ44_iqTN4sf1aZ8UY86g7uIyDcZNpm3EW5jL2IhtJpAzEuCbJqBd_yZvB2xe5Q8YhyQt6XFUYQVWScEX/s72-c/C+program+to+write+heap+sort+output.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7376754541559761952.post-3639864702355916708</guid><pubDate>Tue, 01 Nov 2011 19:21:00 +0000</pubDate><atom:updated>2011-11-17T02:51:10.743-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">print</category><category domain="http://www.blogger.com/atom/ns#">recursion</category><title>c program to print n numbers without using loop</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
This program will print the n numbers without using any loop. Here we uses the concept of recursion. Lets See the program&lt;br /&gt;
to make clear view that how recursion works.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
&lt;div style=&quot;overflow-x: scroll; overflow-y: scroll; padding-bottom: 10px; width: 550px;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;conio.h&amp;gt;

void print(int p)
{
&amp;nbsp; if(p&amp;gt;0)
&amp;nbsp; {
&amp;nbsp; &amp;nbsp; print(p-1); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// recursive call;
&amp;nbsp; &amp;nbsp; printf(&quot;\n\n %d \t&quot;, p);
&amp;nbsp; }
&amp;nbsp; return;
}

int main()
{
&amp;nbsp; int n;
&amp;nbsp; printf(&quot;enter the number\n\n&quot;);
&amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// number to which you wnat to print
&amp;nbsp; print(n);
&amp;nbsp; getch();
&amp;nbsp; return 0;
}

&lt;/div&gt;&lt;/code&gt;
&lt;/pre&gt;&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUmAy13vJXtdVfA7AbkN5vGYAwx9IB35R83y4Tmjp_nyIubkUyL_jOrCNFWlN32wUAyzaeAq9WA4EMgYbjx252qWsNaMtz2z-OLzbACf3Fst93XImkd-S2Za3R4kP43ImslXI-SsQMRpHW/s1600/c+program+to+print+n+numbers+without+using+loop.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;C program to print n numbers, withou loop&quot; border=&quot;0&quot; height=&quot;98&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUmAy13vJXtdVfA7AbkN5vGYAwx9IB35R83y4Tmjp_nyIubkUyL_jOrCNFWlN32wUAyzaeAq9WA4EMgYbjx252qWsNaMtz2z-OLzbACf3Fst93XImkd-S2Za3R4kP43ImslXI-SsQMRpHW/s320/c+program+to+print+n+numbers+without+using+loop.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.&lt;/div&gt;</description><link>http://program-in-c.blogspot.com/2011/11/write-c-program-to-print-n-numbers.html</link><author>noreply@blogger.com (akshay)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUmAy13vJXtdVfA7AbkN5vGYAwx9IB35R83y4Tmjp_nyIubkUyL_jOrCNFWlN32wUAyzaeAq9WA4EMgYbjx252qWsNaMtz2z-OLzbACf3Fst93XImkd-S2Za3R4kP43ImslXI-SsQMRpHW/s72-c/c+program+to+print+n+numbers+without+using+loop.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7376754541559761952.post-6169943944286085620</guid><pubDate>Tue, 01 Nov 2011 18:59:00 +0000</pubDate><atom:updated>2011-11-17T02:51:22.907-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">call by value</category><category domain="http://www.blogger.com/atom/ns#">swapping</category><title>c program to swap two numbers using call by value</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
This program demonstrates &lt;b&gt;how the two number are swapped.&lt;/b&gt; This swapping of variables are done in function &#39;swap&#39; which&amp;nbsp;we have defined. It also clears the concept, that how &lt;b&gt;&quot;call by value&quot;&lt;/b&gt; is implemented. Lets see how this is implemented :&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
&lt;div style=&quot;overflow-x: scroll; overflow-y: scroll; padding-bottom: 10px; width: 550px;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

int swap(int , int); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Declaration of function

main( )
{
int a = 10, b = 20 ; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // call by value
swap(a,b); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// a and b are actual parameters
printf ( &quot;\na = %d b = %d&quot;, a, b ) ;
getch();
}

int swap( int x, int y ) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// x and y are formal parameters
{
int t ;
t = x ;
x = y ;
y = t ;
printf ( &quot;\nx = %d y = %d&quot;, x, y ) ;
}

&lt;/div&gt;&lt;/code&gt;
&lt;/pre&gt;&lt;b&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGJH7whm4w7BDBfyvngbLwFF_f14JwiPkW4ngT7a3gMSacW3CgT98A1osNZYwM6MaWf0IJkC3fb_6xTeLRVK6ttRopYVrrMmC-A1h9EYfPUAWyB2mg0_wGoTMurLKgHj4GYjgKIUPF2jH7/s1600/c+program+to+swap+two+numbers+using+call+by+value.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;C program to swap numbers, call by value&quot; border=&quot;0&quot; height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGJH7whm4w7BDBfyvngbLwFF_f14JwiPkW4ngT7a3gMSacW3CgT98A1osNZYwM6MaWf0IJkC3fb_6xTeLRVK6ttRopYVrrMmC-A1h9EYfPUAWyB2mg0_wGoTMurLKgHj4GYjgKIUPF2jH7/s320/c+program+to+swap+two+numbers+using+call+by+value.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that values of a and b remain unchanged even after&lt;br /&gt;
exchanging the values of x and y.&lt;br /&gt;
&lt;br /&gt;
Lets have a look on second method of swapping the number using call by reference :&lt;br /&gt;
here is the link provided for :&lt;br /&gt;
Call by refrence&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.&lt;/div&gt;</description><link>http://program-in-c.blogspot.com/2011/11/write-c-program-to-swap-two-numbers.html</link><author>noreply@blogger.com (akshay)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGJH7whm4w7BDBfyvngbLwFF_f14JwiPkW4ngT7a3gMSacW3CgT98A1osNZYwM6MaWf0IJkC3fb_6xTeLRVK6ttRopYVrrMmC-A1h9EYfPUAWyB2mg0_wGoTMurLKgHj4GYjgKIUPF2jH7/s72-c/c+program+to+swap+two+numbers+using+call+by+value.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7376754541559761952.post-2720819224154597694</guid><pubDate>Tue, 01 Nov 2011 18:45:00 +0000</pubDate><atom:updated>2011-11-17T02:51:37.850-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">call by reference</category><category domain="http://www.blogger.com/atom/ns#">swapping</category><title>c program to swap two numbers using call by reference</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
This is another program to &lt;b&gt;swap two number using call by reference method&lt;/b&gt;. In call by reference the addresses of actual&lt;br /&gt;
arguments in the calling function are copied into formal arguments of the called function. This means that using these addresses we&lt;br /&gt;
would have an access to the actual arguments and hence we would be able to manipulate them.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
&lt;div style=&quot;overflow-x: scroll; overflow-y: scroll; padding-bottom: 10px; width: 550px;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

void swap( int *x, int *y ) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // call by refrence
{
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int t ;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;t = *x ;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;*x = *y ;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;*y = t ;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf( &quot;\nx = %d y = %d&quot;, *x,*y);
}

int main( )
{
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int a = 10, b = 20 ; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;swap ( &amp;amp;a, &amp;amp;b ) ; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// passing the address of values to be swapped
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf ( &quot;\na = %d b = %d&quot;, a, b ) ;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;getch();
}

&lt;/div&gt;&lt;/code&gt;
&lt;/pre&gt;&lt;br /&gt;
output :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihl3WtOJa7CaRiU79UdpAMo3ZNXyMQ7cf9ZadsILw74XF4yIKuymp7Qq7__x-Sp92WSLxG92z6dh6Zk1eu2NXne4VqaQwjkY7pzgnfJpngqHp3SK627I2NI4KPF4gvN0XcX56xMKVadIRV/s1600/c+program+to+swap+two+numbers+using+call+by+refrence.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot; C program to swap two numbers using call by reference output&quot; border=&quot;0&quot; height=&quot;154&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihl3WtOJa7CaRiU79UdpAMo3ZNXyMQ7cf9ZadsILw74XF4yIKuymp7Qq7__x-Sp92WSLxG92z6dh6Zk1eu2NXne4VqaQwjkY7pzgnfJpngqHp3SK627I2NI4KPF4gvN0XcX56xMKVadIRV/s320/c+program+to+swap+two+numbers+using+call+by+refrence.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that this program manages to exchange the values of a and b&lt;br /&gt;
using their addresses stored in x and y.&lt;br /&gt;
Lets have a look on how call by value is done. Here is the program to swap two numbers using call by value :&lt;br /&gt;
Call by value&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.&lt;/div&gt;</description><link>http://program-in-c.blogspot.com/2011/11/write-c-program-to-swap-two-numbers_01.html</link><author>noreply@blogger.com (akshay)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihl3WtOJa7CaRiU79UdpAMo3ZNXyMQ7cf9ZadsILw74XF4yIKuymp7Qq7__x-Sp92WSLxG92z6dh6Zk1eu2NXne4VqaQwjkY7pzgnfJpngqHp3SK627I2NI4KPF4gvN0XcX56xMKVadIRV/s72-c/c+program+to+swap+two+numbers+using+call+by+refrence.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7376754541559761952.post-4345210726343459049</guid><pubDate>Tue, 01 Nov 2011 18:30:00 +0000</pubDate><atom:updated>2011-11-17T02:51:46.343-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">swapping</category><title>c program to swap two numbers without using third variable</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This is another important&lt;b&gt; program to swap two numbers without using third variable&lt;/b&gt;. The bold letters indicated in this program&lt;br /&gt;
describe the concept of how swapping is made withou using any other variable. Below is the program which is implementing swaping of two numbers. &lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
&lt;div style=&quot;overflow-x: scroll; overflow-y: scroll; padding-bottom: 10px; width: 550px;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;stdio.h&gt;
#include&amp;lt;conio.h&amp;gt;&lt;conio.h&gt;

int main()
{
int a,b,temp;
printf(&quot;enter two values\n&quot;);
printf(&quot;\na = &quot;);
scanf(&quot;%d&quot;,&amp;amp;a);
printf(&quot;\tb = &quot;);
scanf(&quot;%d&quot;,&amp;amp;b);
&lt;b&gt;a=a+b;                       // swapping without using third variable
b=a-b;
a=a-b;&lt;/b&gt;
printf(&quot;\na = %d\tb = %d &quot;, a, b);
getch();
}

&lt;/conio.h&gt;&lt;/stdio.h&gt;&lt;/div&gt;&lt;/code&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhznTn9ur7H96E_ziZMU0GoFgUumWfrV2iqfI3B2cZZ5owLlr6IViwLGyQbPXM2-h3yi0sxsdycHqWzTv3qd5BIGQ1be_LI6ef6lb6lJkJQU2Zd9EWEioMQmsGNjVv5z3Vg3JVsTNkiZmll/s1600/c+program+to+swap+two+number+without+using+third+variable.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;C program to swap without using third variable &quot; border=&quot;0&quot; height=&quot;158&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhznTn9ur7H96E_ziZMU0GoFgUumWfrV2iqfI3B2cZZ5owLlr6IViwLGyQbPXM2-h3yi0sxsdycHqWzTv3qd5BIGQ1be_LI6ef6lb6lJkJQU2Zd9EWEioMQmsGNjVv5z3Vg3JVsTNkiZmll/s320/c+program+to+swap+two+number+without+using+third+variable.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.&lt;/div&gt;</description><link>http://program-in-c.blogspot.com/2011/11/write-c-program-to-swap-two-numbers_6173.html</link><author>noreply@blogger.com (akshay)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhznTn9ur7H96E_ziZMU0GoFgUumWfrV2iqfI3B2cZZ5owLlr6IViwLGyQbPXM2-h3yi0sxsdycHqWzTv3qd5BIGQ1be_LI6ef6lb6lJkJQU2Zd9EWEioMQmsGNjVv5z3Vg3JVsTNkiZmll/s72-c/c+program+to+swap+two+number+without+using+third+variable.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7376754541559761952.post-2141315692954106603</guid><pubDate>Tue, 01 Nov 2011 03:12:00 +0000</pubDate><atom:updated>2011-11-17T02:51:54.793-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">swapping</category><title>c program to swap two numbers using third variable</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Hello! This&lt;b&gt; program is very important &lt;/b&gt;as it is mostly taught and asked in external, vivas and some time in &lt;br /&gt;
campus recruitment exams also. We are &lt;b&gt;Swapping the value&lt;/b&gt; of variable &#39;a&#39; and &#39;b&#39; by using a third variable &#39;temp&#39;. Lets look&amp;nbsp;on this program that how it is done.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
&lt;div style=&quot;overflow-x: scroll; overflow-y: scroll; padding-bottom: 10px; width: 550px;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;


&lt;div&gt;&lt;/div&gt;int main()
{
&amp;nbsp; &amp;nbsp; int a,b,temp;
&amp;nbsp; &amp;nbsp;printf(&quot;enter two values\n&quot;);
&amp;nbsp; &amp;nbsp;printf(&quot;\na = &quot;);
&amp;nbsp; &amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;a);
&amp;nbsp; &amp;nbsp;printf(&quot;\nb = &quot;);
&amp;nbsp; &amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;b);
&amp;nbsp; &amp;nbsp;temp=a;
&amp;nbsp; &amp;nbsp;a=b;
&amp;nbsp; &amp;nbsp;b=temp;
&amp;nbsp; &amp;nbsp;printf(&quot;\na = %d\tb = %d &quot;, a, b);
&amp;nbsp; &amp;nbsp;getch();
}
&lt;/div&gt;&lt;/code&gt;
&lt;/pre&gt;&lt;br /&gt;
Output : &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5SKYVKtianeTvgEKfB37QxDj-LfonTKwBMA8UYk9bOBG3NRyGjT4l-2PiUMPfCw5o9A55mzyDbyySt66dvUlpQH03A20nmgJTQEi_ehfHKZs7_ffMliRI-rUtxad4-VqyX0V7Ea3MhgPf/s1600/c+program+to+swap+two+number+using+third+variable.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot; C program to swap two numbers using third variable&quot; border=&quot;0&quot; height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5SKYVKtianeTvgEKfB37QxDj-LfonTKwBMA8UYk9bOBG3NRyGjT4l-2PiUMPfCw5o9A55mzyDbyySt66dvUlpQH03A20nmgJTQEi_ehfHKZs7_ffMliRI-rUtxad4-VqyX0V7Ea3MhgPf/s320/c+program+to+swap+two+number+using+third+variable.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;C program to swap two number using third varaible&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.&lt;/div&gt;</description><link>http://program-in-c.blogspot.com/2011/10/write-c-program-to-swap-two-numbers.html</link><author>noreply@blogger.com (akshay)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5SKYVKtianeTvgEKfB37QxDj-LfonTKwBMA8UYk9bOBG3NRyGjT4l-2PiUMPfCw5o9A55mzyDbyySt66dvUlpQH03A20nmgJTQEi_ehfHKZs7_ffMliRI-rUtxad4-VqyX0V7Ea3MhgPf/s72-c/c+program+to+swap+two+number+using+third+variable.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7376754541559761952.post-52847008814217090</guid><pubDate>Fri, 28 Oct 2011 19:27:00 +0000</pubDate><atom:updated>2011-11-17T02:53:49.353-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">prime number</category><category domain="http://www.blogger.com/atom/ns#">recursion</category><title>c program to find whether the given number is prime or not using Recursion ?</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
This&lt;b&gt; C program uses recursion for finding whether the entered number is prime or not&lt;/b&gt;. A function is called recursive if&amp;nbsp;the statement in a body calls the same functions. It uses the modulus operator (&#39;%&#39;) to find the prime number.Lets have a look on this program. Function name is prime in this program and it calls prime() again till the condition is satisfied&amp;nbsp;and till the parser is not return to the main function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;&lt;/code&gt;&lt;div style=&quot;overflow-x: scroll; padding-bottom: 10px; width: 550px;&quot;&gt;&lt;code&gt;#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

int prime(int n)
{
&amp;nbsp; &amp;nbsp; static int i=2; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(n%i==0&amp;amp;&amp;amp;n!=2)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return(1);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(i&amp;lt;n)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;i++;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;prime(n); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// recursion call
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
}
int main()
{
&amp;nbsp; &amp;nbsp; int p;
&amp;nbsp; &amp;nbsp; printf(&quot;enter the number to check for prime number : &quot;);
&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;p);
&amp;nbsp; &amp;nbsp; int l=prime(p); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//function returns the value and puts in &#39;l&#39; variable
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(l==1) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//conditions
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d is not a prime number &quot;, p);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d is a prime number &quot;, p);
&amp;nbsp; &amp;nbsp; getch();
}
&lt;/code&gt;
&lt;/div&gt;&lt;/pre&gt;&lt;br /&gt;
Here is output for the above program :&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp6k9vbsVuQOYvSyxTLLGeIDd8I9bEyKNklqJ0jhmQxoirBaAMyPsVVzsglDWvoC00ac6e0JD3fcVpPLRX8JWfnP8fG4owVUFvmjM-diD6idCSyIomi_ymKUWURJiqZQ7cq3B6TM2JzbCh/s1600/c+program+to+find+prime+number+by+recursion.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;C program to find whether the entered number is prime or not using recursion&quot; border=&quot;0&quot; height=&quot;130&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp6k9vbsVuQOYvSyxTLLGeIDd8I9bEyKNklqJ0jhmQxoirBaAMyPsVVzsglDWvoC00ac6e0JD3fcVpPLRX8JWfnP8fG4owVUFvmjM-diD6idCSyIomi_ymKUWURJiqZQ7cq3B6TM2JzbCh/s320/c+program+to+find+prime+number+by+recursion.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;output : Find prime number using recursion&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.&lt;/div&gt;</description><link>http://program-in-c.blogspot.com/2011/10/write-c-program-to-find-whether-given.html</link><author>noreply@blogger.com (akshay)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp6k9vbsVuQOYvSyxTLLGeIDd8I9bEyKNklqJ0jhmQxoirBaAMyPsVVzsglDWvoC00ac6e0JD3fcVpPLRX8JWfnP8fG4owVUFvmjM-diD6idCSyIomi_ymKUWURJiqZQ7cq3B6TM2JzbCh/s72-c/c+program+to+find+prime+number+by+recursion.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7376754541559761952.post-4297179469127190482</guid><pubDate>Fri, 28 Oct 2011 19:25:00 +0000</pubDate><atom:updated>2011-11-17T02:53:59.009-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">goto</category><category domain="http://www.blogger.com/atom/ns#">prime number</category><title>c program to find and count the prime number upto given number ?</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
This&lt;b&gt; program find the Prime number upto the number you desire and will also count the number of prime numbers&lt;/b&gt;. This program&amp;nbsp;uses &lt;b&gt;goto Statement&lt;/b&gt;&amp;nbsp;which is very infrequently used but sometime desired at some places and so as here. So in this program&amp;nbsp;will we also learn to use goto statement. Below is the program with its output, with &lt;b&gt;prime number upto 100&lt;/b&gt;.&lt;br /&gt;
Have a look on it :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;conio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;int n=2, count=0; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//count variable store the number of prime number&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;int i, m;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;enter the number upto which you want to find prime numbers : &quot;); &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;m);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;prime numbers are : &quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;while(n&amp;lt;m)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for(i=2; i&amp;lt;n; i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(n%i==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; goto t; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // goto is&amp;nbsp;referring&amp;nbsp;to line or code &#39;t&#39;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\t%d &quot;, n);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;count++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;t : n++; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//when goto is executed it will directly jump to this statement&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\n\nNumber of prime numbers are %d&quot;,count);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;getch();&lt;br /&gt;
}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
Here is the output :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFLAABy9wJZ0fSnmzB39hOXOCVdpPneplxWg8RJn5Mxmgl1NuCVdX-Vh7c4jexD2avFspLyLwATfIHmILBoU2oE9YLmrH_yq9tLZ2hVlFcNpYPjp3ZChhu2cWFJXt2IrBRlLsDzfDNKsjZ/s1600/c+program+to+find+the+prime+number+upto+a+given+number+and+to+count+the+number+of+prime+number.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;c program to find the prime number upto a given number and count total number of prime numbers&quot; border=&quot;0&quot; height=&quot;155&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFLAABy9wJZ0fSnmzB39hOXOCVdpPneplxWg8RJn5Mxmgl1NuCVdX-Vh7c4jexD2avFspLyLwATfIHmILBoU2oE9YLmrH_yq9tLZ2hVlFcNpYPjp3ZChhu2cWFJXt2IrBRlLsDzfDNKsjZ/s320/c+program+to+find+the+prime+number+upto+a+given+number+and+to+count+the+number+of+prime+number.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.&lt;/div&gt;</description><link>http://program-in-c.blogspot.com/2011/10/write-c-program-to-find-and-count-prime.html</link><author>noreply@blogger.com (akshay)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFLAABy9wJZ0fSnmzB39hOXOCVdpPneplxWg8RJn5Mxmgl1NuCVdX-Vh7c4jexD2avFspLyLwATfIHmILBoU2oE9YLmrH_yq9tLZ2hVlFcNpYPjp3ZChhu2cWFJXt2IrBRlLsDzfDNKsjZ/s72-c/c+program+to+find+the+prime+number+upto+a+given+number+and+to+count+the+number+of+prime+number.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7376754541559761952.post-8081217729214859466</guid><pubDate>Fri, 28 Oct 2011 19:22:00 +0000</pubDate><atom:updated>2011-11-17T02:54:14.738-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">prime number</category><title>c program to find prime number efficiently in less time ?</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
This C program will find the given number is prime with less time, by testing whether the given number is a multiple of any integer between 2 and square root of that&amp;nbsp;number. Lets take an example to understand this. Suppose the number is 21, then rather to check its divisibility from 2 to 20, just test it divisibility only by 2, 3, and 4.As square of 4 is 16 and that of 5 is 25 which is greater than 21. The below program will let you know how this is done.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;
&lt;div style=&quot;overflow-x: scroll; overflow-y: scroll; padding-bottom: 10px; width: 550px;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

int main()
{
&amp;nbsp; &amp;nbsp; &amp;nbsp;int n;
&amp;nbsp; &amp;nbsp; &amp;nbsp;int i,s=1,p=1;
&amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;enter the number :&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp;scanf(&quot;%d&quot;,&amp;amp;n);
&amp;nbsp; &amp;nbsp; &amp;nbsp;while(p&amp;lt;n)
&amp;nbsp; &amp;nbsp; &amp;nbsp;{
&amp;nbsp; &amp;nbsp; &amp;nbsp;s++;
&amp;nbsp; &amp;nbsp; &amp;nbsp;p=s*s;
&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;\nDivisibility is checked till number %d \n\n&quot;,s-1);
&amp;nbsp; &amp;nbsp; &amp;nbsp;for(i=2; i&amp;lt;s; i++)
&amp;nbsp; &amp;nbsp; &amp;nbsp;{
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(n%i==0)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d is not a prime number&quot;, n);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;getch();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return (1);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}
&amp;nbsp; &amp;nbsp; &amp;nbsp; }
printf(&quot;%d is a prime number&quot;, n);
getch();
}
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&amp;nbsp; &amp;nbsp; 

&lt;/div&gt;&lt;/code&gt;
&lt;/pre&gt;&lt;br /&gt;
Here is the output :&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinGobd-JTPDmELMFxO-OqHsp6CyTT_coB1XbzFAC216Hy406vpQ1JWuMWJ-6Dl6eNZvfw0RM8LbVnWWfTV9uhUabCI9vuwTV9aVPaj1Qdabs0VqYN4KvbOwQ3domadLff7PjenZRO0vaJq/s1600/c+program+to+find+prime+number+effeciently+in+less+time.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;C program to find prime number effeciently in less time and fast&quot; border=&quot;0&quot; height=&quot;165&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinGobd-JTPDmELMFxO-OqHsp6CyTT_coB1XbzFAC216Hy406vpQ1JWuMWJ-6Dl6eNZvfw0RM8LbVnWWfTV9uhUabCI9vuwTV9aVPaj1Qdabs0VqYN4KvbOwQ3domadLff7PjenZRO0vaJq/s320/c+program+to+find+prime+number+effeciently+in+less+time.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&amp;nbsp;find prime number efficiently in less time&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.&lt;/div&gt;</description><link>http://program-in-c.blogspot.com/2011/10/write-c-program-to-find-prime-number.html</link><author>noreply@blogger.com (akshay)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinGobd-JTPDmELMFxO-OqHsp6CyTT_coB1XbzFAC216Hy406vpQ1JWuMWJ-6Dl6eNZvfw0RM8LbVnWWfTV9uhUabCI9vuwTV9aVPaj1Qdabs0VqYN4KvbOwQ3domadLff7PjenZRO0vaJq/s72-c/c+program+to+find+prime+number+effeciently+in+less+time.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7376754541559761952.post-9214244288914370048</guid><pubDate>Fri, 28 Oct 2011 17:29:00 +0000</pubDate><atom:updated>2011-11-17T02:54:23.260-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">prime number</category><title>c program to find whether the given number  is prime or not ?</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;div style=&quot;color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Nimbus Sans L&#39;, sans-serif; font-size: 15px; font-style: inherit; font: normal normal normal 15px/normal &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; line-height: 1.625; margin-bottom: 1.625em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: 300;&quot;&gt;In this C program, we will input the number when program runs and find whether that entered &lt;/span&gt;&lt;b&gt;number is prime or not&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: 300;&quot;&gt;. &lt;/span&gt;&lt;b&gt;This program uses &quot;%&quot; or &quot;modulus&quot;&lt;/b&gt; operator which gives the remainder of two numbers when it is divided. For example : &lt;b&gt;7 % 2 = 1&lt;/b&gt;, as 1 is remainder when 7 is divided by 2. So if the number is not prime then its % operation will give output &#39;0&#39; otherwise it is prime. Let us see how this program is implemented.&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Nimbus Sans L&#39;, sans-serif; font-size: 15px; font-style: inherit; font-weight: 300; font: normal normal normal 15px/normal &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; line-height: 1.625; margin-bottom: 1.625em;&quot;&gt;#include&amp;lt;stdio.h&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Including library&lt;br /&gt;
#include&amp;lt;conio.h&amp;gt;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Nimbus Sans L&#39;, sans-serif; font-size: 15px; font-style: inherit; font-weight: 300; font: normal normal normal 15px/normal &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; line-height: 1.625; margin-bottom: 1.625em;&quot;&gt;int main() &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int n;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot; enter the number : &quot;);&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;n);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=2; i&amp;lt;n; i++)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(n%i==0)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;%d is not a prime number.&quot;, n);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getch(); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// hold&amp;nbsp; the&amp;nbsp; screen to display the above message&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (1); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// return statement&amp;nbsp; will return the value and terimate&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
printf(&quot;%d is a prime number.&quot;, n);&lt;br /&gt;
getch();&lt;br /&gt;
}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Nimbus Sans L&#39;, sans-serif; font-size: 15px; font-style: inherit; font-weight: 300; font: normal normal normal 15px/normal &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; line-height: 1.625; margin-bottom: 1.625em;&quot;&gt;Lets see the output of this program&lt;/div&gt;&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4M_zxf_B_LAmfweLx6HswxHwO6MsP-LqXlRvg8blgSbGfjJz0wqFZgMURhyphenhypheneXRn-KP_fTOcizIK1mbcjCDJEKX-mAmIQTEU_1gcXyqFKGKadBTBtDHQKjf3lltv3mO3mm7YR97XfK1YAH/s1600/prime+number.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;c program to find prime number, output for prime number &quot; border=&quot;0&quot; height=&quot;96&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4M_zxf_B_LAmfweLx6HswxHwO6MsP-LqXlRvg8blgSbGfjJz0wqFZgMURhyphenhypheneXRn-KP_fTOcizIK1mbcjCDJEKX-mAmIQTEU_1gcXyqFKGKadBTBtDHQKjf3lltv3mO3mm7YR97XfK1YAH/s320/prime+number.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;output : Program to find prime number&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div style=&quot;color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Nimbus Sans L&#39;, sans-serif; font-size: 15px; font-style: inherit; font-weight: 300; font: normal normal normal 15px/normal &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; line-height: 1.625; margin-bottom: 1.625em;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 15px/normal &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; margin-bottom: 1.625em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Nimbus Sans L&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: inherit; line-height: 1.625;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 15px/normal &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; margin-bottom: 1.625em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Nimbus Sans L&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: inherit; line-height: 1.625;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 15px/normal &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; margin-bottom: 1.625em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Nimbus Sans L&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: inherit; line-height: 1.625;&quot;&gt;Here’s the another&amp;nbsp; program to find&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 24px;&quot;&gt;whether&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Nimbus Sans L&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: inherit; line-height: 1.625;&quot;&gt;&amp;nbsp; the given number is prime or not by using recursion function.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 15px/normal &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; margin-bottom: 1.625em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Nimbus Sans L&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: inherit; line-height: 1.625;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font: normal normal normal 15px/normal &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; margin-bottom: 1.625em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, &#39;Nimbus Sans L&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: inherit; line-height: 1.625;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;This blog will contain c programs related to interview preparation, basic programs, operating system, graphics, data structure, algorithms implementation, compiler and porjects. C is one of the most widely used programming languages of all time. This blog is intended for engineer students and for the people who are preparing for their interview in IT sector.&lt;/div&gt;</description><link>http://program-in-c.blogspot.com/2011/10/write-c-program-to-find-whether-given_28.html</link><author>noreply@blogger.com (akshay)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4M_zxf_B_LAmfweLx6HswxHwO6MsP-LqXlRvg8blgSbGfjJz0wqFZgMURhyphenhypheneXRn-KP_fTOcizIK1mbcjCDJEKX-mAmIQTEU_1gcXyqFKGKadBTBtDHQKjf3lltv3mO3mm7YR97XfK1YAH/s72-c/prime+number.png" height="72" width="72"/><thr:total>0</thr:total></item></channel></rss>