<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Technotip.com</title>
	<atom:link href="http://technotip.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://technotip.com</link>
	<description>Code is poetry!</description>
	<lastBuildDate>Sat, 19 May 2012 12:47:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Linear Search: C</title>
		<link>http://technotip.com/1533/linear-search-c/</link>
		<comments>http://technotip.com/1533/linear-search-c/#comments</comments>
		<pubDate>Mon, 02 Apr 2012 11:01:19 +0000</pubDate>
		<dc:creator>Satish</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[linear search]]></category>

		<guid isPermaLink="false">http://technotip.com/?p=1533</guid>
		<description><![CDATA[In this video tutorial we shall see how we can search for a number in an array in linear fashion. First ask the user to enter the number to be searched. Store it inside a variable called key. Now start comparing key value with a[i] using a for loop. If the key is found in [...]
Related posts:<ol>
<li><a href='http://technotip.com/1522/find-biggest-in-an-array-without-sorting-it-c/' rel='bookmark' title='Find Biggest In An Array, Without Sorting It: C'>Find Biggest In An Array, Without Sorting It: C</a></li>
<li><a href='http://technotip.com/1516/bubble-sort-c/' rel='bookmark' title='Bubble Sort: C'>Bubble Sort: C</a></li>
<li><a href='http://technotip.com/1524/find-first-and-second-biggest-in-an-array-without-sorting-it-c/' rel='bookmark' title='Find First and Second Biggest In An Array, Without Sorting It: C'>Find First and Second Biggest In An Array, Without Sorting It: C</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In this video tutorial we shall see how we can search for a number in an array in linear fashion.</p>
<p>First ask the user to enter the number to be searched. Store it inside a variable called key.<br />
Now start comparing key value with a[i] using a for loop. If the key is found in the array, then assign 1 to flag orelse flag will be 0.</p>
<p>Depending upon the value of flag, print the message.</p>
<p>If flag is 1, search is successful.<br />
If flag is 0, search failed. in the sense, the number is not present in the given array.</p>
<p><strong>Video Tutorial: Linear Search: C</strong><br />
<center><br />
<a href="http://technotip.com/1533/linear-search-c/"><img src="http://img.youtube.com/vi/AqjVd6FVFbE/default.jpg" width="130" height="97" border title="Linear Search: C" alt="default Linear Search: C" /></a><br />
</center></p>
<div style="font-size: small;">YouTube Link: <a href="http://www.youtube.com/watch?v=AqjVd6FVFbE&#038;fmt=22">http://www.youtube.com/watch?v=AqjVd6FVFbE</a> [Watch the Video In Full Screen.]</div>
<p><br style="clear: both;" /><br />
</p>
<p><b>Full Source Code</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">#include &lt; stdio.h &gt;
#include &lt; conio.h &gt;
&nbsp;
void main()
{
	int a[20], key, N, flag = 0, i;
	clrscr();
&nbsp;
	printf(&quot;Enter array limit\n&quot;);
	scanf(&quot;%d&quot;, &amp;N);
&nbsp;
	printf(&quot;Enter %d elements\n&quot;, N);
	for(i=0; i &lt; N; i++)
	 scanf(&quot;%d&quot;,&amp;a[i]);
&nbsp;
	printf(&quot;Enter the number to be searched\n&quot;);
	scanf(&quot;%d&quot;, &amp;key);
&nbsp;
	for( i=0; i &lt; N; i++)
	 if( a[i] == key )
	 {
		flag = 1;
		break;
	 }
&nbsp;
	if(flag)
		printf(&quot;\nSearch Successful\n&quot;);
	else
		printf(&quot;\nSearch Failed\n&quot;);
	getch();
}</pre></td></tr></table></div>

<p><strong>Output</strong><br />
Enter array limit<br />
5<br />
Enter 5 elements<br />
77<br />
0<br />
13<br />
9<br />
55<br />
Enter the number to be searched<br />
9<br />
Search Successful</pre>
<p>Related posts:<ol>
<li><a href='http://technotip.com/1522/find-biggest-in-an-array-without-sorting-it-c/' rel='bookmark' title='Find Biggest In An Array, Without Sorting It: C'>Find Biggest In An Array, Without Sorting It: C</a></li>
<li><a href='http://technotip.com/1516/bubble-sort-c/' rel='bookmark' title='Bubble Sort: C'>Bubble Sort: C</a></li>
<li><a href='http://technotip.com/1524/find-first-and-second-biggest-in-an-array-without-sorting-it-c/' rel='bookmark' title='Find First and Second Biggest In An Array, Without Sorting It: C'>Find First and Second Biggest In An Array, Without Sorting It: C</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://technotip.com/1533/linear-search-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find First and Second Biggest In An Array, Without Sorting It: C</title>
		<link>http://technotip.com/1524/find-first-and-second-biggest-in-an-array-without-sorting-it-c/</link>
		<comments>http://technotip.com/1524/find-first-and-second-biggest-in-an-array-without-sorting-it-c/#comments</comments>
		<pubDate>Mon, 02 Apr 2012 06:44:38 +0000</pubDate>
		<dc:creator>Satish</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[first big]]></category>
		<category><![CDATA[no sorting]]></category>
		<category><![CDATA[second big]]></category>
		<category><![CDATA[swap]]></category>

		<guid isPermaLink="false">http://technotip.com/?p=1524</guid>
		<description><![CDATA[We assume that a[0] has first biggest and a[1] has the second biggest value. Now check if this assumption is correct, if not, swap the values. &#160; if( sbig &#62; fbig ) { temp = sbig; sbig = fbig; fbig = temp; } Now since we have already checked with a[0] and a[1], we start [...]
Related posts:<ol>
<li><a href='http://technotip.com/1522/find-biggest-in-an-array-without-sorting-it-c/' rel='bookmark' title='Find Biggest In An Array, Without Sorting It: C'>Find Biggest In An Array, Without Sorting It: C</a></li>
<li><a href='http://technotip.com/1206/find-biggest-of-2-numbers-cpp/' rel='bookmark' title='Find Biggest of 2 Numbers: C++'>Find Biggest of 2 Numbers: C++</a></li>
<li><a href='http://technotip.com/1238/biggest-of-3-numbers-cpp/' rel='bookmark' title='Find Biggest of 3 Numbers: C++'>Find Biggest of 3 Numbers: C++</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>We assume that a[0] has first biggest and a[1] has the second biggest value.</p>
<p>Now check if this assumption is correct, if not, swap the values.</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">&nbsp;
 if( sbig &gt; fbig )
 {
    temp = sbig;
    sbig = fbig;
    fbig = temp;
 }</pre></div></div>

<p>Now since we have already checked with a[0] and a[1], we start the comparison from a[2], till N.</p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">for(i=2; i &lt; n ; i++)
	 if(a[i] &gt; fbig)
	 {
		sbig = fbig;
		fbig = a[i];
	 }
	 else if(a[i] &gt; sbig)
		sbig = a[i];</pre></div></div>

<p>Now, if a[i] contains a number which is bigger than fbig, we transfer the value of a[i] to fbig and the value present in fbig to sbig;<br />
If the value of a[i] is not bigger than fbig, then we check it with sbig. If a[i] is bigger than sbig, then we assign the value of a[i] to sbig.</p>
<p>This way, at the end of the loop fbig will have the first biggest and sbig will have the second biggest element/number in the array.</p>
<p><b>Video Tutorial: Find First and Second Biggest In An Array, Without Sorting It: C</b><br />
<center><br />
<a href="http://technotip.com/1524/find-first-and-second-biggest-in-an-array-without-sorting-it-c/"><img src="http://img.youtube.com/vi/DzZvT87WuGQ/default.jpg" width="130" height="97" border title="Find First and Second Biggest In An Array, Without Sorting It: C" alt="default Find First and Second Biggest In An Array, Without Sorting It: C" /></a><br />
</center></p>
<div style="font-size: small;">YouTube Link: <a href="http://www.youtube.com/watch?v=DzZvT87WuGQ&#038;fmt=22">http://www.youtube.com/watch?v=DzZvT87WuGQ</a> [Watch the Video In Full Screen.]</div>
<p><br style="clear: both;" /><br />
</p>
<p><b>Full source code</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">#include &lt; stdio.h &gt;
#include &lt; conio.h &gt;
&nbsp;
void main()
{
	int a[20], N, i, fbig, sbig, temp;
	clrscr();
&nbsp;
	printf(&quot;Enter array limit\n&quot;);
	scanf(&quot;%d&quot;, &amp;N);
&nbsp;
	printf(&quot;Enter %d array elements\n&quot;, N);
	for(i=0; i &lt; n ; i++)
	 scanf(&quot;%d&quot;, &amp;a[i]);
&nbsp;
	fbig = a[0];
	sbig = a[1];
&nbsp;
	if( sbig &gt; fbig )
	{
	   temp = sbig;
	   sbig = fbig;
	   fbig = temp;
	}
&nbsp;
	for(i=2; i &lt; n ; i++)
	 if(a[i] &gt; fbig)
	 {
		sbig = fbig;
		fbig = a[i];
	 }
	 else if(a[i] &gt; sbig)
		sbig = a[i];
&nbsp;
	 printf(&quot;First Big is %d and Second big is %d&quot;, fbig, sbig);
&nbsp;
	 getch();
&nbsp;
}</pre></td></tr></table></div>

<p><strong>Output:</strong><br />
Enter array limit<br />
6<br />
Enter 6 array elements<br />
99<br />
108<br />
777<br />
723<br />
786<br />
999<br />
First Big is 999 and Second big is 786</p>
<p>Related posts:<ol>
<li><a href='http://technotip.com/1522/find-biggest-in-an-array-without-sorting-it-c/' rel='bookmark' title='Find Biggest In An Array, Without Sorting It: C'>Find Biggest In An Array, Without Sorting It: C</a></li>
<li><a href='http://technotip.com/1206/find-biggest-of-2-numbers-cpp/' rel='bookmark' title='Find Biggest of 2 Numbers: C++'>Find Biggest of 2 Numbers: C++</a></li>
<li><a href='http://technotip.com/1238/biggest-of-3-numbers-cpp/' rel='bookmark' title='Find Biggest of 3 Numbers: C++'>Find Biggest of 3 Numbers: C++</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://technotip.com/1524/find-first-and-second-biggest-in-an-array-without-sorting-it-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find Biggest In An Array, Without Sorting It: C</title>
		<link>http://technotip.com/1522/find-biggest-in-an-array-without-sorting-it-c/</link>
		<comments>http://technotip.com/1522/find-biggest-in-an-array-without-sorting-it-c/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 17:14:58 +0000</pubDate>
		<dc:creator>Satish</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[biggest]]></category>
		<category><![CDATA[without sorting]]></category>

		<guid isPermaLink="false">http://technotip.com/?p=1522</guid>
		<description><![CDATA[First we have to assume that a[0] is biggest. Now store the value of a[0] inside a variable called big. Now compare value of big with other values in the array. If big is less than any other value, then store the bigger value inside variable big. Video Tutorial: Biggest In An Array, Without Sorting [...]
Related posts:<ol>
<li><a href='http://technotip.com/1206/find-biggest-of-2-numbers-cpp/' rel='bookmark' title='Find Biggest of 2 Numbers: C++'>Find Biggest of 2 Numbers: C++</a></li>
<li><a href='http://technotip.com/1238/biggest-of-3-numbers-cpp/' rel='bookmark' title='Find Biggest of 3 Numbers: C++'>Find Biggest of 3 Numbers: C++</a></li>
<li><a href='http://technotip.com/1217/biggest-of-two-numbers-using-ternary-operator-cpp/' rel='bookmark' title='Biggest of Two Numbers Using Ternary Operator: C++'>Biggest of Two Numbers Using Ternary Operator: C++</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>First we have to assume that a[0] is biggest. Now store the value of a[0] inside a variable called <strong>big</strong>. Now compare value of big with other values in the array. If big is less than any other value, then store the bigger value inside variable <strong>big</strong>.</p>
<p><b>Video Tutorial: Biggest In An Array, Without Sorting It: C</b><br />
<center><br />
<a href="http://technotip.com/1522/find-biggest-in-an-array-without-sorting-it-c/"><img src="http://img.youtube.com/vi/tKaImGrxgKo/default.jpg" width="130" height="97" border title="Find Biggest In An Array, Without Sorting It: C" alt="default Find Biggest In An Array, Without Sorting It: C" /></a><br />
</center></p>
<div style="font-size: small;">YouTube Link: <a href="http://www.youtube.com/watch?v=tKaImGrxgKo&#038;fmt=22">http://www.youtube.com/watch?v=tKaImGrxgKo</a> [Watch the Video In Full Screen.]</div>
<p><br style="clear: both;" /><br />
</p>
<p>Note that, the previous value inside the variable <strong>big</strong> is discarded.</p>
<p><b>Full source code</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&nbsp;
#include &lt; stdio.h &gt;
#include &lt; conio.h &gt;
&nbsp;
void main()
{
	int big, a[20], N, pos, i;
	clrscr();
&nbsp;
	printf(&quot;Enter the array size\n&quot;);
	scanf(&quot;%d&quot;, &amp;N);
&nbsp;
	printf(&quot;Enter %d elements\n&quot;, N);
	for(i=0; i&lt;n ; i++)
	 scanf(&quot;%d&quot;, &amp;a[i]);
&nbsp;
	big = a[0];
	pos = 0;
&nbsp;
	for(i=1; i&lt;N; i++)
	 if(a[i] &gt; big)
	 {
	  big = a[i];
	  pos = i+1;
&nbsp;
	 }
&nbsp;
	 printf(&quot;Big is %d and its position is %d&quot;, big, pos);
&nbsp;
	 getch();
}
&nbsp;
&lt;/n&gt;</pre></td></tr></table></div>

<p><strong>Output</strong><br />
Enter the array size<br />
5<br />
Enter 5 elements<br />
2<br />
0<br />
100<br />
108<br />
55<br />
Big is 108 and its position is 4</p>
<p>Related posts:<ol>
<li><a href='http://technotip.com/1206/find-biggest-of-2-numbers-cpp/' rel='bookmark' title='Find Biggest of 2 Numbers: C++'>Find Biggest of 2 Numbers: C++</a></li>
<li><a href='http://technotip.com/1238/biggest-of-3-numbers-cpp/' rel='bookmark' title='Find Biggest of 3 Numbers: C++'>Find Biggest of 3 Numbers: C++</a></li>
<li><a href='http://technotip.com/1217/biggest-of-two-numbers-using-ternary-operator-cpp/' rel='bookmark' title='Biggest of Two Numbers Using Ternary Operator: C++'>Biggest of Two Numbers Using Ternary Operator: C++</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://technotip.com/1522/find-biggest-in-an-array-without-sorting-it-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bubble Sort: C</title>
		<link>http://technotip.com/1516/bubble-sort-c/</link>
		<comments>http://technotip.com/1516/bubble-sort-c/#comments</comments>
		<pubDate>Fri, 30 Mar 2012 14:47:45 +0000</pubDate>
		<dc:creator>Satish</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[5 arrays]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[bubble sort]]></category>
		<category><![CDATA[n array]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://technotip.com/?p=1516</guid>
		<description><![CDATA[In this video tutorial we illustrate the bubble sort algorithm and also see how to write it in C programming, for 5 elements as well as to N elements. In bubble sort, a[0] is compared with a[1]. a[1] with a[2], a[2] with a[3] .. so on if a[0] is greater than a[1], the values are [...]
Related posts:<ol>
<li><a href='http://technotip.com/1509/selection-sort-of-n-numbers-c/' rel='bookmark' title='Selection Sort of N numbers: C'>Selection Sort of N numbers: C</a></li>
<li><a href='http://technotip.com/1277/array-basic-in-cpp-find-sum/' rel='bookmark' title='Array Basics in C++ : Find Sum'>Array Basics in C++ : Find Sum</a></li>
<li><a href='http://technotip.com/1363/basic-find-sum-using-dynamic-memory-allocation-cpp/' rel='bookmark' title='(Basic) Find Sum Using Dynamic Memory Allocation: C++'>(Basic) Find Sum Using Dynamic Memory Allocation: C++</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In this video tutorial we illustrate the bubble sort algorithm and also see how to write it in C programming, for 5 elements as well as to N elements.</p>
<p>In bubble sort, a[0] is compared with a[1]. a[1] with a[2], a[2] with a[3] .. so on<br />
if a[0] is greater than a[1], the values are swapped. This logic continues till the end of the array.</p>
<p>At the end of each iteration, 1 element gets sorted.</p>
<p>If the array size is 5, then we will have 4 iterations. i.e., if size is N, then we will have N-1 iterations.</p>
<p><center><img src="http://technotip.com/wp-content/uploads/C/bubble-sort/Bubble-sort-example-300px.gif" width="300" height="180" title="Bubble Sort: C" alt="Bubble sort example 300px Bubble Sort: C" /></center></p>
<p><br style="clear: both;" /><br />
<b>Bubble Sort: Full source code for 5 elements</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">#include &lt; stdio.h &gt;
#include &lt; conio.h &gt;
&nbsp;
void main()
{
	int a[5] = { 15, 0, -2, 8, 3 };
	int i, j, temp;
	clrscr();
&nbsp;
	printf(&quot;Array elements are..\n&quot;);
	for( i=0; i&amp;lt;5; i++)
	 printf(&quot;\n%d&quot;, a[i]);
&nbsp;
	for(j=3; j&gt;=0; j--)
	 for(i=0; i&lt; =j; i++)
	  if( a[i] &gt; a[i+1] )
	  {
	    temp = a[i];
	    a[i] = a[i+1];
	    a[i+1] = temp;
	  }
&nbsp;
	printf(&quot;\nafter sorting..\n&quot;);
	for(i=0; i&amp;lt;5; i++)
	 printf(&quot;\n%d&quot;, a[i]);
&nbsp;
	getch();
}</pre></td></tr></table></div>

<p><strong>Output:</strong><br />
Array elements are..<br />
15<br />
0<br />
-2<br />
8<br />
3</p>
<p>after sorting..<br />
-2<br />
0<br />
3<br />
8<br />
15</p>
<p><b>Video Tutorial: Bubble Sort: C</b><br />
<center><br />
<a href="http://technotip.com/1516/bubble-sort-c/"><img src="http://img.youtube.com/vi/Ne9QNWuGJvw/default.jpg" width="130" height="97" border title="Bubble Sort: C" alt="default Bubble Sort: C" /></a><br />
</center></p>
<div style="font-size: small;">YouTube Link: <a href="http://www.youtube.com/watch?v=Ne9QNWuGJvw&#038;fmt=22">http://www.youtube.com/watch?v=Ne9QNWuGJvw</a> [Watch the Video In Full Screen.]</div>
<p><br style="clear: both;" /><br />
</p>
<p><b>Bubble Sort: Full source code for N elements</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">#include &lt; stdio.h &gt;
#include &lt; conio.h &gt;
&nbsp;
void main()
{
	int a[20];
	int i, j, temp, N;
	clrscr();
&nbsp;
	printf(&quot;\nEnter array size\n&quot;);
	scanf(&quot;%d&quot;, &amp;N);
&nbsp;
	printf(&quot;Enter %d elements\n&quot;, N);
	for(i=0; i&lt;n ; i++)
	 scanf(&quot;\n%d&quot;, &amp;a[i]);
&nbsp;
	printf(&quot;Array elements are..\n&quot;);
	for( i=0; i&lt;N; i++)
	 printf(&quot;\n%d&quot;, a[i]);
&nbsp;
	for(j=N-2; j&gt;=0; j--)
	 for(i=0; i&lt; =j; i++)
	  if( a[i] &gt; a[i+1] )
	  {
	    temp = a[i];
	    a[i] = a[i+1];
	    a[i+1] = temp;
	  }
&nbsp;
	printf(&quot;\nafter sorting..\n&quot;);
	for(i=0; i&lt;/n&gt;&lt;n ; i++)
	 printf(&quot;\n%d&quot;, a[i]);
&nbsp;
	getch();
}</pre></td></tr></table></div>

<p><strong>Output:</strong><br />
Enter array size<br />
10<br />
Enter 10 elements<br />
20<br />
19<br />
18<br />
17<br />
16<br />
15<br />
14<br />
13<br />
12<br />
11</p>
<p>Array elements are..<br />
20<br />
19<br />
18<br />
17<br />
16<br />
15<br />
14<br />
13<br />
12<br />
11</p>
<p>after sorting..<br />
11<br />
12<br />
13<br />
14<br />
15<br />
16<br />
17<br />
18<br />
19<br />
20</n></pre>
<p>Related posts:<ol>
<li><a href='http://technotip.com/1509/selection-sort-of-n-numbers-c/' rel='bookmark' title='Selection Sort of N numbers: C'>Selection Sort of N numbers: C</a></li>
<li><a href='http://technotip.com/1277/array-basic-in-cpp-find-sum/' rel='bookmark' title='Array Basics in C++ : Find Sum'>Array Basics in C++ : Find Sum</a></li>
<li><a href='http://technotip.com/1363/basic-find-sum-using-dynamic-memory-allocation-cpp/' rel='bookmark' title='(Basic) Find Sum Using Dynamic Memory Allocation: C++'>(Basic) Find Sum Using Dynamic Memory Allocation: C++</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://technotip.com/1516/bubble-sort-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selection Sort of N numbers: C</title>
		<link>http://technotip.com/1509/selection-sort-of-n-numbers-c/</link>
		<comments>http://technotip.com/1509/selection-sort-of-n-numbers-c/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 11:43:28 +0000</pubDate>
		<dc:creator>Satish</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[N numbers]]></category>
		<category><![CDATA[selection sort]]></category>

		<guid isPermaLink="false">http://technotip.com/?p=1509</guid>
		<description><![CDATA[Selection sort is a sorting technique which is inefficient on large list of elements. Its simple and easy to understand. In selection sort, first we select one element and compare it with the rest of the elements. If the compared element is smaller than the selected element, then those numbers are sorted. This approach is [...]
Related posts:<ol>
<li><a href='http://technotip.com/1277/array-basic-in-cpp-find-sum/' rel='bookmark' title='Array Basics in C++ : Find Sum'>Array Basics in C++ : Find Sum</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Selection sort is a sorting technique which is inefficient on large list of elements. Its simple and easy to understand.</p>
<p>In selection sort, first we select one element and compare it with the rest of the elements. If the compared element is smaller than the selected element, then those numbers are sorted. This approach is continued till the last element in the array index.</p>
<p>The number of iterations is 1 less than the array size.<br />
i.e., if the user enters array size as 5, then there will be 4 iterations.</p>
<p><strong>Below is an example:</strong><br />
Lets assume, user has entered the array size as 5.<br />
and entered 13, 0, -2, 8, 3 as array elements.<br />
<br style="clear: both;" /><br />
<strong>First Iteration:</strong></p>
<p><center><img width="541" height="480" src="http://technotip.com/wp-content/uploads/C/selection-sort/selection-sort-first-iteration.png" alt="selection sort first iteration Selection Sort of N numbers: C"  title="Selection Sort of N numbers: C" /></center></p>
<p><br style="clear: both;" /><br />
In first iteration, a[0] is selected. and is compared with a[1], a[2], a[3] and a[4]. and is swapped with the least value in the array.</p>
<p><br style="clear: both;" /></p>
<p><strong>Second Iteration:</strong></p>
<p><center><img width="541" height="325" src="http://technotip.com/wp-content/uploads/C/selection-sort/selection-sort-second-iteration.png" alt="selection sort second iteration Selection Sort of N numbers: C"  title="Selection Sort of N numbers: C" /></center></p>
<p><br style="clear: both;" /><br />
In the second iteration, we leave off a[0] and select a[1] and compare it with the rest of the elements in the array i.e., a[2], a[3] and a[4]. and swap the least value with a[1]</p>
<p><strong>Third Iteration:</strong></p>
<p><center><img width="541" height="325" src="http://technotip.com/wp-content/uploads/C/selection-sort/selection-sort-third-iteration.png" alt="selection sort third iteration Selection Sort of N numbers: C"  title="Selection Sort of N numbers: C" /></center></p>
<p><br style="clear: both;" /><br />
In third iteration, we select a[2] and compare it with a[3], a[4] and swap the least value to a[2]<br />
<br style="clear: both;" /><br />
<strong>Forth Iteration:</strong></p>
<p><center><img width="541" height="325" src="http://technotip.com/wp-content/uploads/C/selection-sort/selection-sort-forth-iteration.png" alt="selection sort forth iteration Selection Sort of N numbers: C"  title="Selection Sort of N numbers: C" /></center></p>
<p><br style="clear: both;" /><br />
In forth iteration, we select a[3] and compare it with a[4] and swap the least value.</p>
<p>At the end of 4 iterations all array elements are sorted.</p>
<p><strong>Video Tutorial: Selection Sort of N numbers: C</strong><br />
<center><br />
<a href="http://technotip.com/1509/selection-sort-of-n-numbers-c/"><img src="http://img.youtube.com/vi/NWLPmRdIPBA/default.jpg" width="130" height="97" border title="Selection Sort of N numbers: C" alt="default Selection Sort of N numbers: C" /></a><br />
</center></p>
<div style="font-size: small;">YouTube Link: <a href="http://www.youtube.com/watch?v=NWLPmRdIPBA&#038;fmt=22">http://www.youtube.com/watch?v=NWLPmRdIPBA</a> [Watch the Video In Full Screen.]</div>
<p><br style="clear: both;" /><br />
</p>
<p>Since the array index starts from 0, and we need not compare the last element in the array with any other elements, we iterate the outer loop from 0 to N-2.<br />
We iterate the inner loop from i+1 till N-1.</p>
<p><b>Full Source Code</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">#include &lt; stdio.h &gt;
#include &lt; conio.h &gt;
&nbsp;
void main()
{
	int a[20], i, j, N, temp;
	clrscr();
&nbsp;
	printf(&quot;Enter the size of the array\n&quot;);
	scanf(&quot;%d&quot;, &amp;N);
&nbsp;
	printf(&quot;Enter %d elements\n&quot;, N);
	for(i=0; i&lt;n ; i++)
	 scanf(&quot;%d&quot;, &amp;a[i]);
&nbsp;
	for( i=0; i&lt;=N-2; i++ )
	 for( j=i+1; j&lt;=N-1; j++)
	  if(a[i] &gt; a[j])
	  {
	     temp = a[i];
	     a[i] = a[j];
	     a[j] = temp;
	  }
&nbsp;
         printf(&quot;\nSorted Array:\n&quot;);
	  for(i=0; i&lt;/n&gt;&lt;n ; i++)
	   printf(&quot;\n%d&quot;, a[i]);
&nbsp;
	   getch();
&nbsp;
}</pre></td></tr></table></div>

<p><strong>Output:</strong><br />
Enter the size of the array<br />
5<br />
Enter 5 elements<br />
13<br />
 0<br />
-2<br />
 8<br />
 3<br />
Sorted Array:<br />
-2<br />
 0<br />
 3<br />
 8<br />
13</n></pre>
<p>Related posts:<ol>
<li><a href='http://technotip.com/1277/array-basic-in-cpp-find-sum/' rel='bookmark' title='Array Basics in C++ : Find Sum'>Array Basics in C++ : Find Sum</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://technotip.com/1509/selection-sort-of-n-numbers-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find the Factorial of a Number: C</title>
		<link>http://technotip.com/1501/factorial-of-a-number-c/</link>
		<comments>http://technotip.com/1501/factorial-of-a-number-c/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 08:40:48 +0000</pubDate>
		<dc:creator>Satish</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[factorial]]></category>

		<guid isPermaLink="false">http://technotip.com/?p=1501</guid>
		<description><![CDATA[This video tutorial illustrates finding factorial of a given number using C programming. In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. Ex: if user enters 5, then the factorial is 1 * 2 * 3 * 4 * [...]
Related posts:<ol>
<li><a href='http://technotip.com/1266/find-the-factorial-of-a-number-cpp/' rel='bookmark' title='Find the Factorial of a Number: C++'>Find the Factorial of a Number: C++</a></li>
<li><a href='http://technotip.com/1474/find-given-number-is-prime-or-not-c/' rel='bookmark' title='Find Given Number Is Prime or Not: C'>Find Given Number Is Prime or Not: C</a></li>
<li><a href='http://technotip.com/1492/find-sum-of-digits-in-a-given-number-c/' rel='bookmark' title='Find Sum of Digits In A Given Number: C'>Find Sum of Digits In A Given Number: C</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This video tutorial illustrates finding factorial of a given number using C programming.</p>
<p>In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n.</p>
<p><strong>Ex:</strong><br />
 if user enters 5, then the factorial is 1 * 2 * 3 * 4 * 5 i.e., factorial = 120<br />
This logic must be handled with a c program.</p>
<p><b>Full Source Code</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">#include &lt; stdio.h &gt;
#include &lt; conio.h &gt;
&nbsp;
void main()
{
	int num, i, fact = 1;
	clrscr();
&nbsp;
	printf(&quot;Enter a number\n&quot;);
	scanf(&quot;%d&quot;, &amp;num);
&nbsp;
	for( i = 1; i &lt; = num; i++ )
	 fact = fact * i;                // fact *= i;
&nbsp;
	printf(&quot;\nFactorial of %d is %d&quot;, num, fact);
&nbsp;
	getch();
&nbsp;
}</pre></td></tr></table></div>

<p>Here the for loop stars from 1 and not 0. As anything multiplied by 0 would also be zero.</p>
<p><strong>Note:</strong> Factorial of 0 is 1. i.e., 0! = 1</p>
<p><center><img width="483" height="534" src="http://technotip.com/wp-content/uploads/cpp/factorial-cpp.png" alt="factorial cpp Find the Factorial of a Number: C"  title="Find the Factorial of a Number: C" /></center></p>
<p><br style="clear: both;" /></p>
<p>
fact *= i; is the compact representation of fact = fact * i;
</p>
<p><b>Video Tutorial: Factorial in c</b><br />
<center><br />
<a href="http://technotip.com/1501/factorial-of-a-number-c/"><img src="http://img.youtube.com/vi/PYLaSrO84nU/default.jpg" width="130" height="97" border title="Find the Factorial of a Number: C" alt="default Find the Factorial of a Number: C" /></a><br />
</center></p>
<div style="font-size: small;">YouTube Link: <a href="http://www.youtube.com/watch?v=PYLaSrO84nU&#038;fmt=22">http://www.youtube.com/watch?v=PYLaSrO84nU</a> [Watch the Video In Full Screen.]</div>
<p><br style="clear: both;" /><br />
</p>
<p><b>Output:</b><br />
Enter a number<br />
5<br />
Factorial of 5 is 120</pre>
<p><strong>Also Watch/Read:</strong> <a href="http://technotip.com/1266/find-the-factorial-of-a-number-cpp/" title="Find the Factorial of a Number: C++">Find the Factorial of a Number: C++</a></p>
<p>Related posts:<ol>
<li><a href='http://technotip.com/1266/find-the-factorial-of-a-number-cpp/' rel='bookmark' title='Find the Factorial of a Number: C++'>Find the Factorial of a Number: C++</a></li>
<li><a href='http://technotip.com/1474/find-given-number-is-prime-or-not-c/' rel='bookmark' title='Find Given Number Is Prime or Not: C'>Find Given Number Is Prime or Not: C</a></li>
<li><a href='http://technotip.com/1492/find-sum-of-digits-in-a-given-number-c/' rel='bookmark' title='Find Sum of Digits In A Given Number: C'>Find Sum of Digits In A Given Number: C</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://technotip.com/1501/factorial-of-a-number-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find Sum of Digits In A Given Number: C</title>
		<link>http://technotip.com/1492/find-sum-of-digits-in-a-given-number-c/</link>
		<comments>http://technotip.com/1492/find-sum-of-digits-in-a-given-number-c/#comments</comments>
		<pubDate>Thu, 15 Mar 2012 10:03:37 +0000</pubDate>
		<dc:creator>Satish</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[interger]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[sum of digits]]></category>

		<guid isPermaLink="false">http://technotip.com/?p=1492</guid>
		<description><![CDATA[Video Tutorial to illustrate, C Program to find sum of digits in the given/user entered integer number. In this program we assign variable sum = 0 to avoid garbage values in sum before the calculation, which would result in wrong output. We store the user entered value in num. 1 2 3 4 5 6 [...]
Related posts:<ol>
<li><a href='http://technotip.com/1341/reverse-given-number-check-palindrome-cpp/' rel='bookmark' title='Reverse Given Number And Check For Palindrome: C++'>Reverse Given Number And Check For Palindrome: C++</a></li>
<li><a href='http://technotip.com/1474/find-given-number-is-prime-or-not-c/' rel='bookmark' title='Find Given Number Is Prime or Not: C'>Find Given Number Is Prime or Not: C</a></li>
<li><a href='http://technotip.com/1277/array-basic-in-cpp-find-sum/' rel='bookmark' title='Array Basics in C++ : Find Sum'>Array Basics in C++ : Find Sum</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Video Tutorial to illustrate, C Program to find sum of digits in the given/user entered integer number.</p>
<p>In this program we assign variable <strong>sum = 0</strong> to avoid garbage values in sum before the calculation, which would result in wrong output.<br />
We store the user entered value in <strong>num</strong>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="language" style="font-family:monospace;"> while( num )
  {
    rem = num % 10;
    sum = sum + rem;
    num = num / 10;
  }</pre></td></tr></table></div>

<p>Here the loop executes until the value of num is zero.</p>
<p>If user enters 123, we apply the modulus to get the individual values.<br />
Ex:<br />
123 % 10 = 3<br />
12  % 10 = 2<br />
1   % 10 = 1</p>
<p>We get 123, 12 and 1 by dividing the original value by 10.<br />
Ex:<br />
123 user entered value.<br />
123 / 10 = 12<br />
12  / 10 = 1</p>
<p>Now the sum. </p>
<p>sum = sum + rem;</p>
<p>3  = 0 + 3<br />
5  = 3 + 2<br />
6  = 5 + 1</p>
<p>So the sum of digits in the given integer number is 6.</p>
<p><b>Video Tutorial: Find Sum of Digits In A Given Number: C</b><br />
<center><br />
<a href="http://technotip.com/1492/find-sum-of-digits-in-a-given-number-c/"><img src="http://img.youtube.com/vi/UnXfCTtHNWw/default.jpg" width="130" height="97" border title="Find Sum of Digits In A Given Number: C" alt="default Find Sum of Digits In A Given Number: C" /></a><br />
</center></p>
<div style="font-size: small;">YouTube Link: <a href="http://www.youtube.com/watch?v=UnXfCTtHNWw&#038;fmt=22">http://www.youtube.com/watch?v=UnXfCTtHNWw</a> [Watch the Video In Full Screen.]</div>
<p><br style="clear: both;" /><br />
</p>
<p><b>Full Free Source code</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">#include &lt; stdio.h &gt;
#include &lt; conio.h &gt;
&nbsp;
void main()
{
	int num, rem, sum = 0;
	clrscr();
&nbsp;
	printf(&quot;Enter an integer number\n&quot;);
	scanf(&quot;%d&quot;, &amp;num);
&nbsp;
	while(num)
	{
	  rem = num % 10;
	  sum = sum + rem;
	  num = num / 10;
	}
&nbsp;
	printf(&quot;\nThe sum of digits is %d&quot;, sum);
	getch();
}</pre></td></tr></table></div>

<p><b>Output:</b><br />
Enter an integer number<br />
123<br />
The sum of digits is 6</p>
<p>Related posts:<ol>
<li><a href='http://technotip.com/1341/reverse-given-number-check-palindrome-cpp/' rel='bookmark' title='Reverse Given Number And Check For Palindrome: C++'>Reverse Given Number And Check For Palindrome: C++</a></li>
<li><a href='http://technotip.com/1474/find-given-number-is-prime-or-not-c/' rel='bookmark' title='Find Given Number Is Prime or Not: C'>Find Given Number Is Prime or Not: C</a></li>
<li><a href='http://technotip.com/1277/array-basic-in-cpp-find-sum/' rel='bookmark' title='Array Basics in C++ : Find Sum'>Array Basics in C++ : Find Sum</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://technotip.com/1492/find-sum-of-digits-in-a-given-number-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find Given Number Is Prime or Not: C</title>
		<link>http://technotip.com/1474/find-given-number-is-prime-or-not-c/</link>
		<comments>http://technotip.com/1474/find-given-number-is-prime-or-not-c/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 15:02:44 +0000</pubDate>
		<dc:creator>Satish</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[prime]]></category>
		<category><![CDATA[sqrt]]></category>

		<guid isPermaLink="false">http://technotip.com/?p=1474</guid>
		<description><![CDATA[A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself. A natural number greater than 1 that is not a prime number is called a composite number. For example, 7 is prime, as only 1 and 7 divide it, whereas 10 is [...]
Related posts:<ol>
<li><a href='http://technotip.com/1266/find-the-factorial-of-a-number-cpp/' rel='bookmark' title='Find the Factorial of a Number: C++'>Find the Factorial of a Number: C++</a></li>
<li><a href='http://technotip.com/1341/reverse-given-number-check-palindrome-cpp/' rel='bookmark' title='Reverse Given Number And Check For Palindrome: C++'>Reverse Given Number And Check For Palindrome: C++</a></li>
<li><a href='http://technotip.com/216/position-left-most-vowel-javascript/' rel='bookmark' title='Find Position of Left most Vowel: JavaScript'>Find Position of Left most Vowel: JavaScript</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself. </p>
<p>A natural number greater than 1 that is not a prime number is called a <strong>composite number</strong>. For example, 7 is prime, as only 1 and 7 divide it, whereas 10 is composite, since it has the divisors 2 and 5 in addition to 1 and 10.</p>
<p>In this video tutorial we show you 3 methods of finding whether the user entered number is a prime number or not.</p>
<p>Since every number is divisible by 1, we start the division(in <strong>for</strong> loop) from 2.</p>
<p><strong>Note:</strong> A number can not be divided(to get a whole number) by another number which is greater than itself. </p>
<p><strong>First Method:</strong><br />
Since every number is divisible by 1, we start the division(in <strong>for</strong> loop) from 2 till one number less than the user entered value.<br />
<strong>Example:</strong> If user entered 10. For loop starts from 2 to 9.<br />
for(i=2; i&lt;10; i++) or for(i=2; i< =9; i++)</p>
<p>But the draw back: If user enters 500, the loop must get executed from 2 till 499. i.e., 497 times.</p>
<p><strong>Second Method:<br />
Here we reduce the number of iterations in for loop.<br />
i.e., we divide the user entered value by 2 and divide the user entered value from 2 till num / 2;<br />
<strong>Example:</strong> If user entered 500, we start the division from 2 till 500/2 i.e., till 250 times.</p>
<p><strong>Third Method:</strong><br />
Here we still reduce the number of iterations in the for loop.<br />
i.e., we take the square root of the user entered number and divide the user entered number from 2 till square root of number.<br />
<strong>Example: </strong> If user entered 500, we start the division from 2 till sqrt(500) i.e., till 22 times.</p>
<p>So this third method is most optimum, as it involves least number of looping.</p>
<p><b>Video Tutorial: Find Given Number Is Prime or Not: C</b><br />
<center><br />
<a href="http://technotip.com/1474/find-given-number-is-prime-or-not-c/"><img src="http://img.youtube.com/vi/3MYx9PrpXEg/default.jpg" width="130" height="97" border title="Find Given Number Is Prime or Not: C" alt="default Find Given Number Is Prime or Not: C" /></a><br />
</center></p>
<div style="font-size: small;">YouTube Link: <a href="http://www.youtube.com/watch?v=3MYx9PrpXEg&#038;fmt=22">http://www.youtube.com/watch?v=3MYx9PrpXEg</a> [Watch the Video In Full Screen.]</div>
<p><br style="clear: both;" /><br />
</p>
<p><strong>Full Free Source Code:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">&nbsp;
#include&lt; stdio .h&gt;
#include&lt; conio .h&gt;
#include&lt; math .h&gt;
&nbsp;
void main()
{
	int num, i, fact, inum;
	clrscr();
&nbsp;
	printf(&quot;Enter a number\n&quot;);
	scanf(&quot;%d&quot;, &amp;num);
&nbsp;
	inum = sqrt(num);
&nbsp;
	for(i=2; i&lt;inum ; i++)
	 if( num % i == 0 )
	 {
	   fact = 0;
	   break;
	 }
	 else
	   fact = 1;
&nbsp;
	if(fact)
	 printf(&quot;%d is Prime\n&quot;, num);
	else
	 printf(&quot;%d is NOT prime\n&quot;, num);
&nbsp;
	getch();
}</pre></td></tr></table></div>

<p><strong>Table of all prime numbers up to 1,000:</strong></p>
<p><center><img src="http://technotip.com/wp-content/uploads/C/prime-numbers-till-1000.png" width="369" height="502" title="Find Given Number Is Prime or Not: C" alt="prime numbers till 1000 Find Given Number Is Prime or Not: C" /></center></p>
<p><br style="clear: both;" /></inum></pre>
<p>Related posts:<ol>
<li><a href='http://technotip.com/1266/find-the-factorial-of-a-number-cpp/' rel='bookmark' title='Find the Factorial of a Number: C++'>Find the Factorial of a Number: C++</a></li>
<li><a href='http://technotip.com/1341/reverse-given-number-check-palindrome-cpp/' rel='bookmark' title='Reverse Given Number And Check For Palindrome: C++'>Reverse Given Number And Check For Palindrome: C++</a></li>
<li><a href='http://technotip.com/216/position-left-most-vowel-javascript/' rel='bookmark' title='Find Position of Left most Vowel: JavaScript'>Find Position of Left most Vowel: JavaScript</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://technotip.com/1474/find-given-number-is-prime-or-not-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Biggest of 2 Numbers Using Function: C++</title>
		<link>http://technotip.com/1375/biggest-of-2-numbers-using-function-cpp/</link>
		<comments>http://technotip.com/1375/biggest-of-2-numbers-using-function-cpp/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 08:57:33 +0000</pubDate>
		<dc:creator>Satish</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[biggest]]></category>
		<category><![CDATA[call]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[definition]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[ternary operator]]></category>

		<guid isPermaLink="false">http://technotip.com/?p=1375</guid>
		<description><![CDATA[Find the biggest of two numbers using function and ternary operator. Basics of functions: A function is a sub program to perform a specific task. OR a group of instructions to perform specific task. Along with main() it is possible to define our own functions by following these steps: 1. Function prototype or Function declaration. [...]
Related posts:<ol>
<li><a href='http://technotip.com/1217/biggest-of-two-numbers-using-ternary-operator-cpp/' rel='bookmark' title='Biggest of Two Numbers Using Ternary Operator: C++'>Biggest of Two Numbers Using Ternary Operator: C++</a></li>
<li><a href='http://technotip.com/1239/biggest-of-3-numbers-using-ternary-operator-cpp/' rel='bookmark' title='Biggest of 3 Numbers Using Ternary Operator: C++'>Biggest of 3 Numbers Using Ternary Operator: C++</a></li>
<li><a href='http://technotip.com/1238/biggest-of-3-numbers-cpp/' rel='bookmark' title='Find Biggest of 3 Numbers: C++'>Find Biggest of 3 Numbers: C++</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Find the biggest of two numbers using function and ternary operator.</p>
<p><b>Basics of functions:</b></p>
<p>A function is a sub program to perform a specific task.<br />
OR<br />
a group of instructions to perform specific task.</p>
<p>Along with main() it is possible to define our own functions by following these steps:<br />
<strong>1.</strong> Function prototype or Function declaration.<br />
<strong>2.</strong> Function call.<br />
<strong>3.</strong> Function definition.</p>
<p><strong>Function Prototype:</strong></p>
<p>Giving information about the function such as return type, function name and arguments type to the compiler is known as function prototype; It is written at the declaration section.<br />
<strong>Syntax:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">&lt; return_type &gt; &lt; function_name &gt;( arguments_type );</pre></div></div>

<p><strong>Example:</strong><br />
int findsum(int a, int b);<br />
float findsum(int a, int b);<br />
void findsum(int a, int b);<br />
int findsum(int a[], int size);<br />
int findsum(int, int);</p>
<p><strong>Function Definition:</strong><br />
Writing the actual code of the function in a block. It is at this stage the task of the function is defined. It is written after the main function.<br />
<strong>Syntax:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">&lt; return_type &gt;&lt; function_name &gt;(parameters)
{
&nbsp;
}</pre></div></div>

<p><strong>Example:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">int findsum(int a, int b)
{
 int sum;
&nbsp;
 sum = a + b;
 return(sum);
}</pre></div></div>

<p><strong>Function Call:</strong><br />
It is a technique used to invoke a function.<br />
<strong>Syntax:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">[variable] &lt; function_name &gt;([arguments]);</pre></div></div>

<p><strong>Example:</strong><br />
res = findsum(10, 20);<br />
res = findsum(x, y);<br />
res = findsum();</p>
<p><strong>Full Source Code:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">#include&lt; iostream.h &gt;
#include&lt; conio.h &gt;
&nbsp;
void main()
{
  int Big(int x,int y);  // Prototype
&nbsp;
  int a, b;
  clrscr();
&nbsp;
  cout&lt; &lt;&quot;Enter 2 numbers\n&quot;;
  cin&gt;&gt;a&gt;&gt;b;
&nbsp;
  int res = Big(a, b);   // Function call
&nbsp;
  cout&lt; &lt;&quot;Biggest = &quot;&lt;&lt;res;
  getch();
}
&nbsp;
int Big(int x, int y)   // Function Definition
{
  return( x&gt;y?x:y );
}</pre></td></tr></table></div>

<p><b>You must also watch these videos, before continuing with this program:</b><br />
<a href="http://technotip.com/1206/find-biggest-of-2-numbers-cpp/" title="Find Biggest of 2 Numbers: C++">Find Biggest of 2 Numbers: C++</a><br />
<a href="http://technotip.com/1217/biggest-of-two-numbers-using-ternary-operator-cpp/" title="Biggest of Two Numbers Using Ternary Operator: C++">Biggest of Two Numbers Using Ternary Operator: C++</a></p>
<p><b>Video Tutorial: Biggest of 2 Numbers Using Function</b><br />
<center><br />
<a href="http://technotip.com/1375/biggest-of-2-numbers-using-function-cpp/"><img src="http://img.youtube.com/vi/mZOaAXL4t9c/default.jpg" width="130" height="97" border title="Biggest of 2 Numbers Using Function: C++" alt="default Biggest of 2 Numbers Using Function: C++" /></a><br />
</center></p>
<div style="font-size: small;">YouTube Link: <a href="http://www.youtube.com/watch?v=mZOaAXL4t9c&#038;fmt=22">http://www.youtube.com/watch?v=mZOaAXL4t9c</a> [Watch the Video In Full Screen.]</div>
<p><br style="clear: both;" /><br />
</p>
<p><b>Output:</b><br />
Enter 2 numbers<br />
420<br />
305<br />
Biggest = 420</p>
<p>Related posts:<ol>
<li><a href='http://technotip.com/1217/biggest-of-two-numbers-using-ternary-operator-cpp/' rel='bookmark' title='Biggest of Two Numbers Using Ternary Operator: C++'>Biggest of Two Numbers Using Ternary Operator: C++</a></li>
<li><a href='http://technotip.com/1239/biggest-of-3-numbers-using-ternary-operator-cpp/' rel='bookmark' title='Biggest of 3 Numbers Using Ternary Operator: C++'>Biggest of 3 Numbers Using Ternary Operator: C++</a></li>
<li><a href='http://technotip.com/1238/biggest-of-3-numbers-cpp/' rel='bookmark' title='Find Biggest of 3 Numbers: C++'>Find Biggest of 3 Numbers: C++</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://technotip.com/1375/biggest-of-2-numbers-using-function-cpp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>(Basic) Find Sum Using Dynamic Memory Allocation: C++</title>
		<link>http://technotip.com/1363/basic-find-sum-using-dynamic-memory-allocation-cpp/</link>
		<comments>http://technotip.com/1363/basic-find-sum-using-dynamic-memory-allocation-cpp/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 09:17:08 +0000</pubDate>
		<dc:creator>Satish</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[deallocation]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[dynamic memory allocation]]></category>
		<category><![CDATA[new]]></category>
		<category><![CDATA[operators]]></category>
		<category><![CDATA[sum]]></category>

		<guid isPermaLink="false">http://technotip.com/?p=1363</guid>
		<description><![CDATA[This video tutorial illustrates basics of Dynamic memory allocation in C++. It shows the use of new and delete operator for allocating and deallocating the memory dynamically. Find the sum of entered elements using dynamic memory allocation in c++. In cpp, dynamic memory management can be done using the operators new and delete. Operator new [...]
Related posts:<ol>
<li><a href='http://technotip.com/1277/array-basic-in-cpp-find-sum/' rel='bookmark' title='Array Basics in C++ : Find Sum'>Array Basics in C++ : Find Sum</a></li>
<li><a href='http://technotip.com/1200/addition-of-2-numbers-cpp/' rel='bookmark' title='Addition of 2 Numbers: C++'>Addition of 2 Numbers: C++</a></li>
<li><a href='http://technotip.com/1341/reverse-given-number-check-palindrome-cpp/' rel='bookmark' title='Reverse Given Number And Check For Palindrome: C++'>Reverse Given Number And Check For Palindrome: C++</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>This video tutorial illustrates basics of Dynamic memory allocation in C++. It shows the use of <strong>new</strong> and <strong>delete</strong> operator for <strong>allocating</strong> and <strong>deallocating</strong> the memory dynamically.</p>
<p>Find the sum of entered elements using dynamic memory allocation in c++.</p>
<p>In cpp, dynamic memory management can be done using the operators <strong>new</strong> and <strong>delete</strong>.<br />
Operator <strong>new</strong> is used to allocate the memory during execution time or run time, the dynamically allocated memory can be freed / released using the operator <strong>delete</strong>.<br />
<b>Syntax:</b></p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">&lt; data_type &gt;  &lt; pointer_variable &gt; = new &lt; data_type &gt;[size];</pre></div></div>

<p><b>Full Source code</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">#include&lt; iostream .h&gt;
#include&lt; conio .h&gt;
&nbsp;
void main()
{
  int sum=0, N;
  clrscr();
&nbsp;
  cout&lt; &lt;&quot;Enter array size\n&quot;;
  cin&gt;&gt;N;
&nbsp;
  int *a = new int[N];
  cout&lt; &lt;&quot;\nEnter &quot;&lt;&lt;N&lt;&lt;&quot; integer numbers&quot;&lt;&lt;endl;
  for(int i=0; i&lt;N; i++)
   cin&gt;&gt;a[i];
&nbsp;
   cout&lt; &lt;&quot;Input array is..&quot;&lt;&lt;endl;
   for(i=0; i&lt;N; i++)
   {
    cout&lt;&lt;a[i]&lt;&lt;endl;
    sum = sum + a[i]; // sum += a[i];
   }
   cout&lt;&lt;&quot;Total Sum: &quot;&lt;&lt;sum;
&nbsp;
   delete(a);
   getch();
}</pre></td></tr></table></div>

<p>We need not include any extra header file to perform dynamic memory allocation or de-allocation.</p>
<p><strong>int *ptr = new int[N];</strong></p>
<p>here it is mandatory to take pointer variable for dynamic memory allocation.</p>
<p>for de-allocation we use delete operator: <strong>delete(ptr);</strong></p>
<p><b>NOTE:</b><br />
<strong>Student *p = new Student[3];</strong></p>
<p>where Student is a user defined data type, maybe structure or class.</p>
<p><strong>Student *p = new Student;</strong> // This is for only 1 student.</p>
<p><b>Video Tutorial:(Basic) Find Sum Using Dynamic Memory Allocation</b><br />
<center><br />
<a href="http://technotip.com/1363/basic-find-sum-using-dynamic-memory-allocation-cpp/"><img src="http://img.youtube.com/vi/Iqqfa-UjONo/default.jpg" width="130" height="97" border title="(Basic) Find Sum Using Dynamic Memory Allocation: C++" alt="default (Basic) Find Sum Using Dynamic Memory Allocation: C++" /></a><br />
</center></p>
<div style="font-size: small;">YouTube Link: <a href="http://www.youtube.com/watch?v=Iqqfa-UjONo&#038;fmt=22">http://www.youtube.com/watch?v=Iqqfa-UjONo</a> [Watch the Video In Full Screen.]</div>
<p><br style="clear: both;" /><br />
</p>
<p><b>Output:</b><br />
Enter array size<br />
5<br />
Enter 5 integer numbers<br />
1<br />
2<br />
3<br />
4<br />
5<br />
Input array is..<br />
1<br />
2<br />
3<br />
4<br />
5<br />
Total Sum: 15</pre>
<p>Related posts:<ol>
<li><a href='http://technotip.com/1277/array-basic-in-cpp-find-sum/' rel='bookmark' title='Array Basics in C++ : Find Sum'>Array Basics in C++ : Find Sum</a></li>
<li><a href='http://technotip.com/1200/addition-of-2-numbers-cpp/' rel='bookmark' title='Addition of 2 Numbers: C++'>Addition of 2 Numbers: C++</a></li>
<li><a href='http://technotip.com/1341/reverse-given-number-check-palindrome-cpp/' rel='bookmark' title='Reverse Given Number And Check For Palindrome: C++'>Reverse Given Number And Check For Palindrome: C++</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://technotip.com/1363/basic-find-sum-using-dynamic-memory-allocation-cpp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reverse Given Number And Check For Palindrome: C++</title>
		<link>http://technotip.com/1341/reverse-given-number-check-palindrome-cpp/</link>
		<comments>http://technotip.com/1341/reverse-given-number-check-palindrome-cpp/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 14:53:17 +0000</pubDate>
		<dc:creator>Satish</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[palindrome]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[reverse]]></category>

		<guid isPermaLink="false">http://technotip.com/?p=1341</guid>
		<description><![CDATA[Cpp program to read a number, reverse the given number and check whether it is palindrome or not. Full Source code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 #include&#60; iostream .h&#62; #include&#60; conio [...]
Related posts:<ol>
<li><a href='http://technotip.com/1277/array-basic-in-cpp-find-sum/' rel='bookmark' title='Array Basics in C++ : Find Sum'>Array Basics in C++ : Find Sum</a></li>
<li><a href='http://technotip.com/1266/find-the-factorial-of-a-number-cpp/' rel='bookmark' title='Find the Factorial of a Number: C++'>Find the Factorial of a Number: C++</a></li>
<li><a href='http://technotip.com/1200/addition-of-2-numbers-cpp/' rel='bookmark' title='Addition of 2 Numbers: C++'>Addition of 2 Numbers: C++</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Cpp program to read a number, reverse the given number and check whether it is palindrome or not.</p>
<p><b>Full Source code</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">#include&lt; iostream .h&gt;
#include&lt; conio .h&gt;
&nbsp;
void main()
{
  int num, rem, sum = 0, temp;
  clrscr();
&nbsp;
  cout&lt; &lt;&quot;Enter a number\n&quot;;
  cin&gt;&gt;num;
&nbsp;
  temp = num;
&nbsp;
  while( num )
  {
    rem = num % 10;
    num = num / 10;
    sum = sum * 10 + rem;
  }
&nbsp;
cout&lt; &lt;&quot;\nReversed Number: &quot;&lt;&lt;sum&lt;&lt;endl;
&nbsp;
  if( temp == sum )
   cout&lt;&lt;temp&lt;&lt;&quot; is a palindrome&quot;;
  else
   cout&lt;&lt;temp&lt;&lt;&quot; in NOT a palindrome&quot;;
&nbsp;
  getch();
}</pre></td></tr></table></div>

<p>In this program we assign variable sum = 0 to avoid garbage values in sum before the calculation, which would result in wrong output.<br />
We store the user entered value in temp, so that we can compare it with the final result, to determine whether the given number is palindrome or not.
</pre>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="language" style="font-family:monospace;"> while( num )
  {
    rem = num % 10;
    num = num / 10;
    sum = sum * 10 + rem;
  }</pre></td></tr></table></div>

<p>Here the loop executes until the value of num is zero.</p>
<p>If user enters 301, we apply the modulus to get the individual values.<br />
Ex:<br />
301 % 10 = 1<br />
30  % 10 = 0<br />
3   % 10 = 3</p>
<p>We get 301, 30 and 3 by dividing the original value by 10.<br />
Ex:<br />
301 user entered value.<br />
301 / 10 = 30<br />
30  / 10 = 3</p>
<p>Now the sum. </p>
<p>sum = sum * 10 + rem;</p>
<p>1   = 0 * 10 + 1<br />
10   = 1 * 10 + 0<br />
103  = 10 * 10 + 3</p>
<p>So the reverse of 301 is 103, which is not a palindrome.</p>
<p><b>Video Tutorial: Reverse Given Number And Check For Palindrome: C++</b><br />
<center><br />
<a href="http://technotip.com/1341/reverse-given-number-check-palindrome-cpp/"><img src="http://img.youtube.com/vi/j8Vv4wgdwoA/default.jpg" width="130" height="97" border title="Reverse Given Number And Check For Palindrome: C++" alt="default Reverse Given Number And Check For Palindrome: C++" /></a><br />
</center></p>
<div style="font-size: small;">YouTube Link: <a href="http://www.youtube.com/watch?v=j8Vv4wgdwoA&#038;fmt=22">http://www.youtube.com/watch?v=j8Vv4wgdwoA</a> [Watch the Video In Full Screen.]</div>
<p><br style="clear: both;" /><br />
</p>
<p><b>Output:</b><br />
Enter a number<br />
301<br />
Reversed Number: 103<br />
301 in NOT a palindrome</p>
<p>Related posts:<ol>
<li><a href='http://technotip.com/1277/array-basic-in-cpp-find-sum/' rel='bookmark' title='Array Basics in C++ : Find Sum'>Array Basics in C++ : Find Sum</a></li>
<li><a href='http://technotip.com/1266/find-the-factorial-of-a-number-cpp/' rel='bookmark' title='Find the Factorial of a Number: C++'>Find the Factorial of a Number: C++</a></li>
<li><a href='http://technotip.com/1200/addition-of-2-numbers-cpp/' rel='bookmark' title='Addition of 2 Numbers: C++'>Addition of 2 Numbers: C++</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://technotip.com/1341/reverse-given-number-check-palindrome-cpp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Array Basics in C++ : Find Sum</title>
		<link>http://technotip.com/1277/array-basic-in-cpp-find-sum/</link>
		<comments>http://technotip.com/1277/array-basic-in-cpp-find-sum/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 13:15:25 +0000</pubDate>
		<dc:creator>Satish</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[declaration]]></category>
		<category><![CDATA[initialization]]></category>
		<category><![CDATA[sum]]></category>

		<guid isPermaLink="false">http://technotip.com/?p=1277</guid>
		<description><![CDATA[Video tutorial to show the basic use of arrays: Initialization, Declaration, Getting values from the users, finding sum of all the array elements etc. Array is a collection of homogeneous data items. Full Source Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [...]
Related posts:<ol>
<li><a href='http://technotip.com/1200/addition-of-2-numbers-cpp/' rel='bookmark' title='Addition of 2 Numbers: C++'>Addition of 2 Numbers: C++</a></li>
<li><a href='http://technotip.com/1053/object-oriented-programming-c/' rel='bookmark' title='Object Oriented Programming: C++'>Object Oriented Programming: C++</a></li>
<li><a href='http://technotip.com/1238/biggest-of-3-numbers-cpp/' rel='bookmark' title='Find Biggest of 3 Numbers: C++'>Find Biggest of 3 Numbers: C++</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Video tutorial to show the basic use of arrays: Initialization, Declaration, Getting values from the users, finding sum of all the array elements etc.</p>
<p>Array is a collection of homogeneous data items.</p>
<p><b>Full Source Code</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">#include&lt;iostream .h&gt;
#include&lt;conio .h&gt;
&nbsp;
void main()
{
  //  int a[5] = { 1, 3, 2, 4, 5 }; declaration with initialization
&nbsp;
  int a[5], sum = 0;
  clrscr();
&nbsp;
  cout&lt; &lt;&quot;Enter 5 numbers\n&quot;;
  for(int i=0; i&amp;lt;5; i++)
   cin&gt;&gt;a[i];
&nbsp;
  cout&lt; &lt;&quot;Input array is..\n&quot;;
  for(i=0; i&amp;lt;5; i++)
  {
   cout&lt;&lt;a[i]&lt;&lt;endl;
   sum = sum + a[i];  // sum += a[i];
  }
  cout&lt;&lt;&quot;Sum of array elements: &quot;&lt;&lt;sum;
&nbsp;
  getch();
&nbsp;
}</pre></td></tr></table></div>

<p>In this program we take input from the user and display the user entered numbers and find the sum of all the array elements and display it as well.</p>
<p>Elements are stored from the index number 0. i.e., if the array size is 5, the values will be stored in a[0], a[1], a[2], a[3], a[4];</p>
<p>Ex:<br />
 int a[5] = { 1, 3, 2, 4, 5 }; declaration with initialization<br />
 float a[5] = { 1.1, 2.0, 3.3, 1.3, 5.6 };</p>
<p><b>Video Tutorial: Array Basics in C++ : Find Sum </b><br />
<center><br />
<a href="http://technotip.com/1277/array-basic-in-cpp-find-sum/"><img src="http://img.youtube.com/vi/BfAa2koJv64/default.jpg" width="130" height="97" border title="Array Basics in C++ : Find Sum" alt="default Array Basics in C++ : Find Sum" /></a><br />
</center></p>
<div style="font-size: small;">YouTube Link: <a href="http://www.youtube.com/watch?v=BfAa2koJv64&#038;fmt=22">http://www.youtube.com/watch?v=BfAa2koJv64</a> [Watch the Video In Full Screen.]</div>
<p><br style="clear: both;" /><br />
</p>
<p><b>Output:</b><br />
Enter 5 numbers<br />
1<br />
2<br />
3<br />
4<br />
5<br />
Input array is..<br />
1<br />
2<br />
3<br />
4<br />
5<br />
Sum of array elements: 15</conio></iostream></pre>
<p>Related posts:<ol>
<li><a href='http://technotip.com/1200/addition-of-2-numbers-cpp/' rel='bookmark' title='Addition of 2 Numbers: C++'>Addition of 2 Numbers: C++</a></li>
<li><a href='http://technotip.com/1053/object-oriented-programming-c/' rel='bookmark' title='Object Oriented Programming: C++'>Object Oriented Programming: C++</a></li>
<li><a href='http://technotip.com/1238/biggest-of-3-numbers-cpp/' rel='bookmark' title='Find Biggest of 3 Numbers: C++'>Find Biggest of 3 Numbers: C++</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://technotip.com/1277/array-basic-in-cpp-find-sum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find the Factorial of a Number: C++</title>
		<link>http://technotip.com/1266/find-the-factorial-of-a-number-cpp/</link>
		<comments>http://technotip.com/1266/find-the-factorial-of-a-number-cpp/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 06:10:39 +0000</pubDate>
		<dc:creator>Satish</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[fact]]></category>
		<category><![CDATA[factorial]]></category>

		<guid isPermaLink="false">http://technotip.com/?p=1266</guid>
		<description><![CDATA[Video tutorial to find the factorial of a number: if the user enters 3, then the factorial is 1 * 2 * 3 i.e., factorial = 6 This logic must be handled with a c++ program. Full Source Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [...]
Related posts:<ol>
<li><a href='http://technotip.com/1238/biggest-of-3-numbers-cpp/' rel='bookmark' title='Find Biggest of 3 Numbers: C++'>Find Biggest of 3 Numbers: C++</a></li>
<li><a href='http://technotip.com/1206/find-biggest-of-2-numbers-cpp/' rel='bookmark' title='Find Biggest of 2 Numbers: C++'>Find Biggest of 2 Numbers: C++</a></li>
<li><a href='http://technotip.com/1200/addition-of-2-numbers-cpp/' rel='bookmark' title='Addition of 2 Numbers: C++'>Addition of 2 Numbers: C++</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Video tutorial to find the factorial of a number: if the user enters 3, then the factorial is 1 * 2 * 3 i.e., factorial = 6<br />
This logic must be handled with a c++ program.</p>
<p><b>Full Source Code</b></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">#include&lt;iostream .h&gt;
#include&lt;conio .h&gt;
&nbsp;
void main()
{
  int fact = 1, N;
  clrscr();
&nbsp;
  cout&lt; &lt;endl&lt;&lt;&quot;Enter a number\n&quot;;
  cin&gt;&gt;N;
&nbsp;
  for( int i=1; i&lt; =N; i++ )
   fact = fact * i;  // OR fact *= i;
&nbsp;
  cout&lt;&lt;endl&lt;&lt;endl&lt;&lt;&quot;Factorial of &quot;&lt;&lt;N&lt;&lt;&quot; is &quot;&lt;&lt;fact;
&nbsp;
  getch();
}</pre></td></tr></table></div>

<p>Here the for loop stars from 1 and not 0. As anything multiplied by 0 would also be zero.</p>
<p><center><img width="483" height="534" src="http://technotip.com/wp-content/uploads/cpp/factorial-cpp.png" alt="factorial cpp Find the Factorial of a Number: C++"  title="Find the Factorial of a Number: C++" /></center></p>
<p><br style="clear: both;" /></p>
<p>
fact *= i; is the compact representation of fact = fact * i;
</p>
<p><b>Video Tutorial: Factorial in cpp</b><br />
<center><br />
<a href="http://technotip.com/1266/find-the-factorial-of-a-number-cpp/"><img src="http://img.youtube.com/vi/ovrdIQZ6Hu8/default.jpg" width="130" height="97" border title="Find the Factorial of a Number: C++" alt="default Find the Factorial of a Number: C++" /></a><br />
</center></p>
<div style="font-size: small;">YouTube Link: <a href="http://www.youtube.com/watch?v=ovrdIQZ6Hu8&#038;fmt=22">http://www.youtube.com/watch?v=ovrdIQZ6Hu8</a> [Watch the Video In Full Screen.]</div>
<p><br style="clear: both;" /><br />
</p>
<p><b>Output:</b><br />
Enter a number<br />
5<br />
Factorial of 5 is 120</conio></iostream></pre>
<p>Related posts:<ol>
<li><a href='http://technotip.com/1238/biggest-of-3-numbers-cpp/' rel='bookmark' title='Find Biggest of 3 Numbers: C++'>Find Biggest of 3 Numbers: C++</a></li>
<li><a href='http://technotip.com/1206/find-biggest-of-2-numbers-cpp/' rel='bookmark' title='Find Biggest of 2 Numbers: C++'>Find Biggest of 2 Numbers: C++</a></li>
<li><a href='http://technotip.com/1200/addition-of-2-numbers-cpp/' rel='bookmark' title='Addition of 2 Numbers: C++'>Addition of 2 Numbers: C++</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://technotip.com/1266/find-the-factorial-of-a-number-cpp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

