<?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>electrofriends.com &#187; Number Programs</title>
	<atom:link href="http://electrofriends.com/category/source-codes/software-programs/c/number-programs/feed/" rel="self" type="application/rss+xml" />
	<link>http://electrofriends.com</link>
	<description>...bringing innovative minds together</description>
	<lastBuildDate>Fri, 30 Apr 2010 05:54:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>C program to calculate the GCD of a number</title>
		<link>http://electrofriends.com/source-codes/software-programs/c/number-programs/c-program-to-calculate-the-gcd-of-a-number/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/c/number-programs/c-program-to-calculate-the-gcd-of-a-number/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 13:04:32 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Number Programs]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[calculate]]></category>
		<category><![CDATA[GCD of a number]]></category>
		<category><![CDATA[Greatest Common Divisor]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1136</guid>
		<description><![CDATA[Write a program to calculate the Greatest Common Divisor(GCD) of a number

#include&#60;stdio.h&#62;
#include&#60;conio.h&#62;
#include&#60;process.h&#62;
int gcd&#40;int m,int n&#41;
&#123;
	int rem;
	while&#40;n!=0&#41;
	&#123;
		rem=m%n;
		m=n;
		n=rem;
	&#125;
	return&#40;m&#41;;
&#125;
main&#40;&#41;
&#123;
	int num1,num2,num3,gcd1,gcd2;
	clrscr&#40;&#41;;
	printf&#40;&#34;Enter three positive integers&#34;&#41;;
	scanf&#40;&#34;%d%d%d&#34;,&#38;num1,&#38;num2,&#38;num3&#41;;
	if&#40;num1==0 &#38;&#38; num2==0 &#38;&#38; num3==0&#41;
	&#123;
		printf&#40;&#34;\n Invalid number&#34;&#41;;
		exit&#40;0&#41;;
	&#125;
	gcd1=gcd&#40;num1,num2&#41;;
	gcd2=gcd&#40;num3,gcd1&#41;;
	printf&#40;&#34;\n GCD of %d %d %d is : %d\n&#34;,num1,num2,num3,gcd2&#41;;
	getch&#40;&#41;;
&#125;

]]></description>
			<content:encoded><![CDATA[<p>Write a program to calculate the Greatest Common Divisor(GCD) of a number</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include&lt;stdio.h&gt;</span>
<span style="color: #339933;">#include&lt;conio.h&gt;</span>
<span style="color: #339933;">#include&lt;process.h&gt;</span>
<span style="color: #993333;">int</span> gcd<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> m<span style="color: #339933;">,</span><span style="color: #993333;">int</span> n<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #993333;">int</span> rem<span style="color: #339933;">;</span>
	<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>n<span style="color: #339933;">!=</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		rem<span style="color: #339933;">=</span>m<span style="color: #339933;">%</span>n<span style="color: #339933;">;</span>
		m<span style="color: #339933;">=</span>n<span style="color: #339933;">;</span>
		n<span style="color: #339933;">=</span>rem<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span><span style="color: #009900;">&#40;</span>m<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #993333;">int</span> num1<span style="color: #339933;">,</span>num2<span style="color: #339933;">,</span>num3<span style="color: #339933;">,</span>gcd1<span style="color: #339933;">,</span>gcd2<span style="color: #339933;">;</span>
	clrscr<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Enter three positive integers&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	scanf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d%d%d&quot;</span><span style="color: #339933;">,&amp;</span>num1<span style="color: #339933;">,&amp;</span>num2<span style="color: #339933;">,&amp;</span>num3<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>num1<span style="color: #339933;">==</span><span style="color: #0000dd;">0</span> <span style="color: #339933;">&amp;&amp;</span> num2<span style="color: #339933;">==</span><span style="color: #0000dd;">0</span> <span style="color: #339933;">&amp;&amp;</span> num3<span style="color: #339933;">==</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span> Invalid number&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	gcd1<span style="color: #339933;">=</span>gcd<span style="color: #009900;">&#40;</span>num1<span style="color: #339933;">,</span>num2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	gcd2<span style="color: #339933;">=</span>gcd<span style="color: #009900;">&#40;</span>num3<span style="color: #339933;">,</span>gcd1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span> GCD of %d %d %d is : %d<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>num1<span style="color: #339933;">,</span>num2<span style="color: #339933;">,</span>num3<span style="color: #339933;">,</span>gcd2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	getch<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/c/number-programs/c-program-to-calculate-the-gcd-of-a-number/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C program for finding remainder</title>
		<link>http://electrofriends.com/source-codes/software-programs/c/number-programs/c-program-for-finding-remainder/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/c/number-programs/c-program-for-finding-remainder/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 04:35:20 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Number Programs]]></category>
		<category><![CDATA[binary remainder]]></category>
		<category><![CDATA[c programs]]></category>
		<category><![CDATA[finding remainder]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=783</guid>
		<description><![CDATA[OUTPUT:
enter frame:
1 0 1 1 0 1 0 0
enter generator:
1 0 1 0
remainder is:
0 0 1 0]]></description>
			<content:encoded><![CDATA[<p>OUTPUT:<br />
enter frame:<br />
1 0 1 1 0 1 0 0<br />
enter generator:<br />
1 0 1 0<br />
remainder is:<br />
0 0 1 0</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
40
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include&lt;stdio.h&gt;</span>
<span style="color: #339933;">#include&lt;conio.h&gt;</span>
<span style="color: #993333;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #993333;">int</span>  i<span style="color: #339933;">,</span>j<span style="color: #339933;">,</span>gen<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>rem<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>frl<span style="color: #339933;">=</span><span style="color: #0000dd;">8</span><span style="color: #339933;">,</span>genl<span style="color: #339933;">=</span><span style="color: #0000dd;">4</span><span style="color: #339933;">,</span>k<span style="color: #339933;">,</span>k1<span style="color: #339933;">,</span>fr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">11</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 clrscr<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;enter frame:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>frl<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span> 
scanf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d&quot;</span><span style="color: #339933;">,&amp;</span>fr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> 
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span>frl<span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span><span style="color: #0000dd;">11</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span> 
fr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;enter generator:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span><span style="color: #0000dd;">4</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
 scanf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d&quot;</span><span style="color: #339933;">,&amp;</span>gen<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>k<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>k<span style="color: #339933;">&lt;</span>frl<span style="color: #339933;">;</span>k<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>fr<span style="color: #009900;">&#91;</span>k<span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
   k1<span style="color: #339933;">=</span>k<span style="color: #339933;">;</span>
    <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span>j<span style="color: #339933;">=</span>k<span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>genl<span style="color: #339933;">;</span>i<span style="color: #339933;">++,</span>j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
     rem<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span>fr<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">^</span>gen<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>genl<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
	  fr<span style="color: #009900;">&#91;</span>k1<span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span>rem<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
     k1<span style="color: #339933;">++;</span>
    <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
      <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>remainder is: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span><span style="color: #0000dd;">4</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
     <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d&quot;</span><span style="color: #339933;">,</span>rem<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     getch<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>OUTPUT:<br />
enter frame:<br />
1 0 1 1 0 1 0 0<br />
enter generator:<br />
1 0 1 0<br />
remainder is:<br />
0 0 1 0</p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/c/number-programs/c-program-for-finding-remainder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>To find the sum of the cos series</title>
		<link>http://electrofriends.com/source-codes/software-programs/c/number-programs/to-find-the-sum-of-the-cos-series/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/c/number-programs/to-find-the-sum-of-the-cos-series/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 06:04:45 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Number Programs]]></category>
		<category><![CDATA[C/C++ Programms]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=345</guid>
		<description><![CDATA[Here is the program to find the Cosine of the given angle for the user defined accuracy. This is a fast, reliable and robust program, which uses no sophisticated functions but a simple while loop and other math functions.
Logic: The program follows the mathematical cosine series, where cosine of the entered radian angle ? is,
The [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the program to find the Cosine of the given angle for the user defined accuracy. This is a fast, reliable and robust program, which uses no sophisticated functions but a simple while loop and other math functions.</p>
<p>Logic: The program follows the mathematical cosine series, where cosine of the entered radian angle ? is,</p>
<p>The program asks the user to enter the Angle x° . Also it asks for the number of iterations &#8216;n&#8217; that the cosine loop should iterate. As the iteration increases, the accuracy boosts up. After the desired loop, the resultant gets printed out. Similar algorithm can be set to find the Sine value of the given number.</p>
<p>#include&lt;stdio.h&gt;<br />
#include&lt;math.h&gt;<br />
void main()<br />
{<br />
float pow = 2.0, nr, dr = 1.0, x1, sum;<br />
int i = 1,n,s = -1,x;<br />
clrscr();<br />
printf(&#8220;\n\n\t ENTER THE ANGLE&#8230;: &#8220;);<br />
scanf(&#8220;%d&#8221;, &amp;x);<br />
x1 = 3.142 * (x / 180.0);<br />
sum = 1.0;<br />
nr = x1*x1;<br />
printf(&#8220;\n\t ENTER THE NUMBER OF TERMS&#8230;: &#8220;);<br />
scanf(&#8220;%d&#8221;,&amp;n);<br />
while(i&lt;=n)<br />
{<br />
dr = dr * pow * (pow &#8211; 1.0);<br />
sum = sum + (nr / (dr * s));<br />
s = s * (-1);<br />
pow = pow + 2.0;<br />
nr = nr * x1 * x1;<br />
i++;<br />
}<br />
printf(&#8220;\n\t THE SUM OF THE COS SERIES IS..: %0.3f&#8221;, sum);<br />
getch();<br />
}<br />
<a href="http://electrofriends.com/wp-content/uploads/2008/12/cos.zip">Download exe and source code here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/c/number-programs/to-find-the-sum-of-the-cos-series/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Program to find the sum of the sine series</title>
		<link>http://electrofriends.com/source-codes/software-programs/c/number-programs/program-to-find-the-sum-of-the-sine-series/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/c/number-programs/program-to-find-the-sum-of-the-sine-series/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 06:01:44 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Number Programs]]></category>
		<category><![CDATA[C/C++ Programms]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=342</guid>
		<description><![CDATA[Here is the program to find the Sinusoidal value of the given angle for the user defined accuracy. This is a fast, reliable and robust program, which uses no built in functions but a simple while loop and other math functions.
Logic: The program follows the mathematical sine series, where cosine of the entered radian angle [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the program to find the Sinusoidal value of the given angle for the user defined accuracy. This is a fast, reliable and robust program, which uses no built in functions but a simple while loop and other math functions.</p>
<p>Logic: The program follows the mathematical sine series, where cosine of the entered radian angle x  is,</p>
<p>The program asks the user to enter the Angle x° . Also it asks for the number of iterations &#8216;n&#8217; that the sine loop should iterate. As the iteration increases, the accuracy boosts up. After the desired loop, the resultant gets printed out. Similar algorithm can be set to find the Cosine value of the given number.</p>
<p>#include&lt;stdio.h&gt;<br />
#include&lt;math.h&gt;<br />
void main()<br />
{<br />
int i = 2, n, s = 1, x, pwr = 1, dr;<br />
float nr = 1, x1, sum;<br />
clrscr();<br />
printf(&#8220;\n\n\t ENTER THE ANGLE&#8230;: &#8220;);<br />
scanf(&#8220;%d&#8221;, &amp;x);<br />
x1 = 3.142 * (x / 180.0);<br />
sum = x1;<br />
printf(&#8220;\n\t ENTER THE NUMBER OF TERMS&#8230;: &#8220;);<br />
scanf(&#8220;%d&#8221;, &amp;n);<br />
while(i &lt;= n)<br />
{<br />
pwr = pwr + 2;<br />
dr = dr * pwr * (pwr &#8211; 1);<br />
sum = sum + (nr / dr) * s;<br />
s = s * (-1);<br />
nr = nr * x1 * x1;<br />
i+= 2;<br />
}<br />
printf(&#8220;\n\t THE SUM OF THE SINE SERIES IS..: %0.3f&#8221;,sum);<br />
getch();<br />
}<br />
<a href="http://electrofriends.com/wp-content/uploads/2008/12/sine.zip">Download exe and source code here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/c/number-programs/program-to-find-the-sum-of-the-sine-series/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>To find the sum of digits</title>
		<link>http://electrofriends.com/source-codes/software-programs/c/number-programs/to-find-the-sum-of-digits/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/c/number-programs/to-find-the-sum-of-digits/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 05:58:40 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Number Programs]]></category>
		<category><![CDATA[C/C++ Programms]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=338</guid>
		<description><![CDATA[Here is the program to find the sum of the digits of the entered number. Main idea in this program is to slice down the given number into digits and to operate on them.
Logic : The program asks the user to enter the number, to find out the sum of its digits. Sets the flag [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the program to find the sum of the digits of the entered number. Main idea in this program is to slice down the given number into digits and to operate on them.</p>
<p><strong>Logic :</strong> The program asks the user to enter the number, to find out the sum of its digits. Sets the flag &#8217;sum&#8217; to zero, implies that sum till now is Nil. Stores the entered number as Num. The while loop slices the number into digits. In each iteration, the current digit gets added up to the flag &#8216;Sum&#8217; . Finally it prints out the number.</p>
<p>The same logic can be implemented for other programs too, where the situation comes to slice up the given number, as in the case of  Reversing the number.</p>
<p>#include&lt;stdio.h&gt;<br />
#include&lt;math.h&gt;<br />
void main()<br />
{<br />
long int num,sum = 0,dig;<br />
clrscr();<br />
printf(&#8220;\n\n\t ENTER A NUMBER&#8230;: &#8220;);<br />
scanf(&#8220;%ld&#8221;,&amp;num);<br />
while(num&gt;0)<br />
{<br />
dig = num % 10;<br />
sum = sum + dig;<br />
num = num / 10;<br />
}<br />
printf(&#8220;\n\t SUM OF DIGITS IS&#8230;: %ld&#8221;, sum);<br />
getch();<br />
}</p>
<p><a href="http://electrofriends.com/wp-content/uploads/2008/12/sum_dig.zip">Download exe and source code here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/c/number-programs/to-find-the-sum-of-digits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>To check whether a given number is palindrome or not</title>
		<link>http://electrofriends.com/source-codes/software-programs/c/number-programs/to-check-whether-a-given-number-is-palindrome-or-not/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/c/number-programs/to-check-whether-a-given-number-is-palindrome-or-not/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 05:55:31 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Number Programs]]></category>
		<category><![CDATA[C/C++ Programms]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=335</guid>
		<description><![CDATA[This is the program to check for the &#8216;Palindrome&#8217; property of the given number. Palindrome is the instinct property of any literal segment, where the segment reads the same either from left to right or vice versa.
For example : 12321 and  LEVEL  are the palindromes as they reads same if we go from right to [...]]]></description>
			<content:encoded><![CDATA[<p>This is the program to check for the &#8216;Palindrome&#8217; property of the given number. Palindrome is the instinct property of any literal segment, where the segment reads the same either from left to right or vice versa.<br />
For example : 12321 and  LEVEL  are the palindromes as they reads same if we go from right to left also.</p>
<p>Logic :  The program expects the user to enter the number to check if palindrome. The entered number is reversed and stored in another variable. Finally the reversed number is checked for equality with the entered number. If they are the same, then it is a palindrome.</p>
<p>A slight change in the code can check if the entered string is a palindrome.</p>
<p>#include&lt;stdio.h&gt;<br />
#include&lt;math.h&gt;<br />
void main()<br />
{<br />
long int n, num, rev = 0, dig;<br />
clrscr();<br />
printf(&#8220;\n\n\t ENTER A NUMBER&#8230;: &#8220;);<br />
scanf(&#8220;%ld&#8221;, &amp;num);<br />
n = num;<br />
while(num&gt;0)<br />
{<br />
dig = num % 10;<br />
rev = rev * 10 + dig;<br />
num = num / 10;<br />
}<br />
if (n == rev)<br />
printf(&#8220;\n\t GIVEN NUMBER IS A PALINDROME&#8221;);<br />
else<br />
printf(&#8220;\n\t GIVEN NUMBER NOT A PALINDROME&#8221;);<br />
getch();<br />
}<br />
<a href="http://electrofriends.com/wp-content/uploads/2008/12/num_pali.zip">Download exe and source code here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/c/number-programs/to-check-whether-a-given-number-is-palindrome-or-not/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>To reverse a given number</title>
		<link>http://electrofriends.com/source-codes/software-programs/c/number-programs/to-reverse-a-given-number/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/c/number-programs/to-reverse-a-given-number/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 05:52:16 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Number Programs]]></category>
		<category><![CDATA[C/C++ Programms]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=331</guid>
		<description><![CDATA[Here is the program to mathematically reverse the entered integer. The program uses simple library functions, and an easy flow.
Logic :  The main idea here is to trace the entered number till its length, and slicing up in each of the iterations. The program asks the user to enter the number to reverse. Sets two [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the program to mathematically reverse the entered integer. The program uses simple library functions, and an easy flow.</p>
<p>Logic :  The main idea here is to trace the entered number till its length, and slicing up in each of the iterations. The program asks the user to enter the number to reverse. Sets two variable flags to hold each digits and the final reversed number.<br />
The while loop slices down the given number to digits, and appends to the reversed flag &#8216;rev&#8217;. Finally it prints out the reversed number after exiting from the while loop.</p>
<p>The similar logic for slicing up the given number is used in other programs like, finding the sum of digits and, palindrome checking programs</p>
<p>#include&lt;stdio.h&gt;<br />
#include&lt;math.h&gt;<br />
void main()<br />
{<br />
long int num, rev = 0, dig;<br />
clrscr();<br />
printf(&#8220;\n\n\t ENTER A NUMBER&#8230;: &#8220;);<br />
scanf(&#8220;%ld&#8221;, &amp;num);<br />
while(num&gt;0)<br />
{<br />
dig = num % 10;<br />
rev = rev * 10 + dig;<br />
num = num / 10;<br />
}<br />
printf(&#8220;\n\t REVERSED NUMBER IS&#8230;: %ld&#8221;, rev);<br />
getch();<br />
}<br />
<a href="http://electrofriends.com/wp-content/uploads/2008/12/rev_num1.zip">Download exe and source code here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/c/number-programs/to-reverse-a-given-number/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Program for Armstrong numbers</title>
		<link>http://electrofriends.com/source-codes/software-programs/c/number-programs/program-for-armstrong-numbers/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/c/number-programs/program-for-armstrong-numbers/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 05:48:00 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Number Programs]]></category>
		<category><![CDATA[C/C++ Programms]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=328</guid>
		<description><![CDATA[Here is the program to calculate the Armstrong numbers, which will fall within the limit, starting from zero. The program expects the user to enter the upper limit.
Definition : Armstrong numbers are the integer numbers , where -the sum of third  power of each digits &#8211; equals to the given number itself.
Logic :  Here we [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the program to calculate the Armstrong numbers, which will fall within the limit, starting from zero. The program expects the user to enter the upper limit.</p>
<p>Definition : Armstrong numbers are the integer numbers , where -the sum of third  power of each digits &#8211; equals to the given number itself.</p>
<p>Logic :  Here we traced the upper limit through a for loop, where in each of the iterations, we are checking if the sum of cubes of its digits equals that integer. If so, displaying the number.</p>
<p>The while loop is  used to slice up a number, which, with a slight modification, can also help us in  many other math related program segments. It needs to include the header &#8220;math.h&#8221;.</p>
<p>Program to find the armstrong numbers below a given number</p>
<p>#include&lt;stdio.h&gt;<br />
#include&lt;math.h&gt;<br />
void main()<br />
{<br />
int lim_up,n,dig,sum,num;<br />
clrscr();<br />
printf(&#8220;\n\n\t ENTER THE UPPER LIMIT&#8230;: &#8220;);<br />
scanf(&#8220;%d&#8221;,&amp;lim_up);<br />
printf(&#8220;\n\n\t ARMSTRONG NUMBERS ARE&#8230;: &#8220;);<br />
for(n=1;n&lt;lim_up;n++)<br />
{<br />
sum = 0;<br />
num = n;<br />
while(num&gt;0)<br />
{<br />
dig = num%10;<br />
sum = sum+pow(dig,3);<br />
num = num/10;<br />
}<br />
if(sum == n)<br />
printf(&#8220;\n\n\t\t\t%d&#8221;,n);<br />
}<br />
getch();<br />
}</p>
<p><a href="http://electrofriends.com/wp-content/uploads/2008/12/arm_bel.zip">Download exe and source code here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/c/number-programs/program-for-armstrong-numbers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Program to find the prime numbers between a given range</title>
		<link>http://electrofriends.com/source-codes/software-programs/c/number-programs/program-to-find-the-prime-numbers-between-a-given-range/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/c/number-programs/program-to-find-the-prime-numbers-between-a-given-range/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 05:43:16 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Number Programs]]></category>
		<category><![CDATA[C/C++ Programms]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=325</guid>
		<description><![CDATA[The program is to find all the prime numbers falls inside the user defined range. A prime number is a one, whose divisors are 1 and the number itself.
Logic: This is advanced version of the previous program. Here, user need to enter two numbers as the lower and upper limits for the iteration loop to [...]]]></description>
			<content:encoded><![CDATA[<p>The program is to find all the prime numbers falls inside the user defined range. A prime number is a one, whose divisors are 1 and the number itself.</p>
<p>Logic: This is advanced version of the previous program. Here, user need to enter two numbers as the lower and upper limits for the iteration loop to find the prime number in between. The outer for loop traces the iteration till the limit, wherein each of iteration inner for loop checks the present number is prime or not, with the prime number&#8217;s logic. If it is, it prints out the present number.</p>
<p>In this program, both the lower limit and the upper limit are variables, and so is flexible. These three programs show, how we can upgrade the logic to make the code flexible one.</p>
<p>The similar growth can be seen in the case of finding the perfect numbers.</p>
<p>Program to find the prime numbers between a given range</p>
<p>#include&lt;stdio.h&gt;<br />
void main()<br />
{<br />
int i, prime, lim_up, lim_low, n;<br />
clrscr();<br />
printf(&#8220;\n\n\t ENTER THE LOWER LIMIT&#8230;: &#8220;);<br />
scanf(&#8220;%d&#8221;, &amp;lim_low);<br />
printf(&#8220;\n\n\t ENTER THE UPPER LIMIT&#8230;: &#8220;);<br />
scanf(&#8220;%d&#8221;, &amp;lim_up);<br />
printf(&#8220;\n\n\t PRIME NUMBERS ARE&#8230;: &#8220;);<br />
for(n=lim_low+1; n&lt;lim_up; n++)<br />
{<br />
prime = 1;<br />
for(i=2; i&lt;n; i++)<br />
if(n%i == 0)<br />
{<br />
prime = 0;<br />
break;<br />
}<br />
if(prime)<br />
printf(&#8220;\n\n\t\t\t%d&#8221;, n);<br />
}<br />
getch();<br />
}<br />
<a href="http://electrofriends.com/wp-content/uploads/2008/12/prim_rng.zip">Download exe and source code here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/c/number-programs/program-to-find-the-prime-numbers-between-a-given-range/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Program to find the prime numbers below a given number.</title>
		<link>http://electrofriends.com/source-codes/software-programs/c/number-programs/program-to-find-the-prime-numbers-below-a-given-number/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/c/number-programs/program-to-find-the-prime-numbers-below-a-given-number/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 05:39:42 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Number Programs]]></category>
		<category><![CDATA[C/C++ Programms]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=322</guid>
		<description><![CDATA[The program is to find all the prime numbers in the range, which starts from zero and ends at user defined limit. A prime number is a one, whose divisors are 1 and the number itself.
Logic: This is a slightly modified version of the previous program. Here, user need to enter the number as the [...]]]></description>
			<content:encoded><![CDATA[<p>The program is to find all the prime numbers in the range, which starts from zero and ends at user defined limit. A prime number is a one, whose divisors are 1 and the number itself.</p>
<p>Logic: This is a slightly modified version of the previous program. Here, user need to enter the number as the upper limit for the for the iteration loop to find the prime number The outer for loop traces the iteration till the limit,, wherein each of iteration inner for loop checks the present number is prime or not, with the previous program&#8217;s logic. If it is, it prints out the present number.</p>
<p>In this program, the lower limit is constant zero. We can change that also, to make the program fully flexible, and to print out all the perfect number between the given range.</p>
<p>Program to find the prime numbers below a given number.</p>
<p>#include&lt;stdio.h&gt;<br />
void main()<br />
{<br />
int i, prime, lim_up, n;<br />
clrscr();<br />
printf(&#8220;\n\n\t ENTER THE UPPER LIMIT&#8230;: &#8220;);<br />
scanf(&#8220;%d&#8221;, &amp;lim_up);<br />
printf(&#8220;\n\n\t PRIME NUMBERS ARE&#8230;: &#8220;);<br />
for(n=1; n&lt;lim_up; n++)<br />
{<br />
prime = 1;<br />
for(i=2; i&lt;n; i++)<br />
if(n%i == 0)<br />
{<br />
prime = 0;<br />
break;<br />
}<br />
if(prime)<br />
printf(&#8220;\n\n\t\t\t%d&#8221;,n);<br />
}<br />
getch();<br />
}<br />
<a href="http://electrofriends.com/wp-content/uploads/2008/12/prim_bel.zip">Download exe and source code here. </a></p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/c/number-programs/program-to-find-the-prime-numbers-below-a-given-number/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
