<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4413331141661636442</id><updated>2024-09-24T15:30:30.996-07:00</updated><category term="C"/><category term="Java"/><category term="C++"/><category term="Computer Graphics"/><category term="Linux"/><category term="Shell script"/><category term="Data Structure"/><title type='text'>Knowledgepedia</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-185109302481954967</id><published>2014-10-24T22:03:00.001-07:00</published><updated>2014-10-24T22:20:19.008-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><title type='text'>C program to convert binary number to decimal</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Given below is a c program to convert binary number to decimal.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Example :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
1111 - Binary Number
&lt;pre&gt;
1        1        1        1  &lt;br/&gt;
2&lt;sup&gt;3&lt;/sup&gt;       2&lt;sup&gt;2&lt;/sup&gt;       2&lt;sup&gt;1&lt;/sup&gt;       2&lt;sup&gt;0&lt;/sup&gt;&lt;br/&gt;
8        4        2        1
&lt;/pre&gt;
2&lt;sup&gt;3&lt;/sup&gt;x1 + 2&lt;sup&gt;2&lt;/sup&gt;x1 + 2&lt;sup&gt;1&lt;/sup&gt;x1 + 2&lt;sup&gt;0&lt;/sup&gt; = 8+4+2+1 = 15
&lt;br/&gt;&lt;br/&gt;
101 - Binary Number
&lt;pre&gt;
1        0        1  &lt;br/&gt;
2&lt;sup&gt;2&lt;/sup&gt;       2&lt;sup&gt;1&lt;/sup&gt;       2&lt;sup&gt;0&lt;/sup&gt;&lt;br/&gt;
4        2        1
&lt;/pre&gt;
2&lt;sup&gt;2&lt;/sup&gt;x1 + 2&lt;sup&gt;1&lt;/sup&gt;x0 + 2&lt;sup&gt;0&lt;/sup&gt; = 4+0+1 = 5
&lt;br /&gt;
&lt;br/&gt;
&lt;b class=&quot;normal&quot;&gt;Links that you may find important :&lt;/b&gt;&lt;br /&gt;
&lt;br/&gt;
&lt;a href=&quot;http://www.wikihow.com/Convert-from-Binary-to-Decimal&quot;&gt;http://www.wikihow.com/Convert-from-Binary-to-Decimal&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://www.binaryhexconverter.com/binary-to-decimal-converter&quot;&gt;http://www.binaryhexconverter.com/binary-to-decimal-converter&lt;/a&gt;&lt;/br&gt;
&lt;br/&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c; tab-size: 8; smart-tabs: false;highlight:[9,13,14,15]&quot;&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;conio.h&amp;gt;
void main()
{    
    long int n,i=1,d=0,m=0,l=0;
    clrscr();
    printf(&quot;Enter binary number : &quot;);
    scanf(&quot;%ld&quot;,&amp;n);
    while(n&amp;gt;0)
    {
        m=(n%10);
        n=(n/10);
        l=m*i;
        d=d+l;
        i=i*2;
    }
    printf(&quot;Decimal equivalent is : %ld&quot;,d);
    getch();
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: text; gutter: false;&quot;&gt;Enter binary number : 1111
Decimal equivalent is : 15
&lt;/pre&gt;

&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; The program above has been tested using TurboCPP. Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/185109302481954967/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2014/10/c-program-to-convert-binary-number-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/185109302481954967'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/185109302481954967'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2014/10/c-program-to-convert-binary-number-to.html' title='C program to convert binary number to decimal'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-2111919141521257391</id><published>2013-09-26T11:25:00.003-07:00</published><updated>2013-09-26T11:30:20.760-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><title type='text'>C program to exchange the values of two variables with and without temporary variable</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Given below is a c program to exchange the values of two variables with and without temporary variable.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Concept (using temporary variable):&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Use a temporary variable(temp) to store the value of a variable(a) and then put the contents of another variable(b) into variable(a) and then put the value of variable(temp) into variable(b).&lt;br /&gt;
&lt;br /&gt;
temp=a;&lt;br/&gt;
a=b;&lt;br /&gt;
b=temp;&lt;br /&gt;
&lt;br/&gt;
&lt;b class=&quot;normal&quot;&gt;Concept (without using temporary variable):&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
a=a-b;&lt;br /&gt;
b=a+b;&lt;br /&gt;
a=b-a&lt;br /&gt;
&lt;br /&gt;

&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c; tab-size: 8; smart-tabs: false;highlight:[10,11,12,16,17,18]&quot;&gt;#include &amp;lt;conio.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
main()
{
    int a=10,b=20,x;
    clrscr();
    printf(&quot;Before swapping\t&quot;);
    printf(&quot;a=%d\tb=%d&quot;,a,b);
    printf(&quot;\nAfter swapping\t&quot;);
    x=a;
    a=b;
    b=x;
    printf(&quot;a=%d\tb=%d&quot;,a,b);
    printf(&quot;\nBefore swapping\t&quot;);
    printf(&quot;a=%d\tb=%d&quot;,a,b);
    a=a-b;
    b=a+b;
    a=b-a;
    printf(&quot;\nAfter swapping\t&quot;);
    printf(&quot;a=%d\tb=%d&quot;,a,b);
    getch();
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: text; gutter: false;&quot;&gt;Before swapping    a=10    b=20
After swapping     a=20    b=10
Before swapping    a=10    b=20
After swapping     a=20    b=10
&lt;/pre&gt;

&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; The program above has been tested using TurboCPP. Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/2111919141521257391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/09/c-program-to-exchange-values-of-two.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/2111919141521257391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/2111919141521257391'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/09/c-program-to-exchange-values-of-two.html' title='C program to exchange the values of two variables with and without temporary variable'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-1530007756321735733</id><published>2013-07-03T00:00:00.000-07:00</published><updated>2013-07-03T22:37:54.958-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><title type='text'>C++ program to calculate m to the power n</title><content type='html'>C++ Program to calculate m to the power n(m raise to n).&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Example :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
2&lt;sup&gt;2&lt;/sup&gt; = 4 which is same as 2 x 2 = 4&lt;br /&gt;
4&lt;sup&gt;4&lt;/sup&gt; = 256 which is same as 4 x 4 x 4 x 4 = 256&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Links that you may find important :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://en.wikipedia.org/wiki/Nth_root&quot;&gt;https://en.wikipedia.org/wiki/Nth_root&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.mathsisfun.com/numbers/nth-root.html&quot;&gt;http://www.mathsisfun.com/numbers/nth-root.html&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.rkm.com.au/calculators/CALCULATOR-powers.html&quot;&gt;http://www.rkm.com.au/calculators/CALCULATOR-powers.html&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.free-online-calculator-use.com/exponent-calculator.html&quot;&gt;http://www.free-online-calculator-use.com/exponent-calculator.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: cpp;&quot;&gt;#include &amp;lt;iostream.h&amp;gt;
#include &amp;lt;conio.h&amp;gt;
int power(int,int);
void main()
{
    int no,pow,val;
    clrscr();
    cout&amp;lt;&amp;lt;&quot;Enter number : &quot;;
    cin&amp;gt;&amp;gt;no;
    cout&amp;lt;&amp;lt;&quot;Enter the power : &quot;;
    cin&amp;gt;&amp;gt;pow;
    val=power(no,pow);//called function power which returns integer
    cout&amp;lt;&amp;lt;&quot;The answer is : &quot;&amp;lt;&amp;lt;val;
    getch();
}
int power(int no, int pow)
{
    int val;
    val=no;
    while(pow&amp;gt;=1)
    {
        if(pow==1)
            return no;
        if(pow&amp;gt;1)
            val=val*no;
        pow--;
    }
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:text;gutter: false;&quot;&gt;Enter number : 2
Enter the power : 8
The answer is : 256
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; Since the type of number is integer the range of number which it can calculate is restricted.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/1530007756321735733/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/07/c-program-to-calculate-m-to-power-n.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/1530007756321735733'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/1530007756321735733'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/07/c-program-to-calculate-m-to-power-n.html' title='C++ program to calculate m to the power n'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-8783344106674354550</id><published>2013-07-02T00:00:00.000-07:00</published><updated>2013-07-03T22:38:31.857-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><title type='text'>Using filters in Linux</title><content type='html'>Examples based on filters in Linux.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Links that you may find important : &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Sort : &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/library/cmd/blcmdl1_sort.htm&quot;&gt;http://linux.about.com/library/cmd/blcmdl1_sort.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/od/commands/a/Example-Uses-Of-The-Command-Sort.htm&quot;&gt;http://linux.about.com/od/commands/a/Example-Uses-Of-The-Command-Sort.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.ibm.com/developerworks/community/blogs/58e72888-6340-46ac-b488-d31aa4058e9c/entry/linux_sort_command_sort_lines_of_text_files9?lang=en&quot;&gt;https://www.ibm.com/developerworks/community/blogs/58e72888-6340-46ac-b488-d31aa4058e9c/entry/linux_sort_command_sort_lines_of_text_files9?lang=en&lt;/a&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;a href=&quot;http://linux.die.net/man/1/sort&quot;&gt;linux.die.net/man/1/sort&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Tee : &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/library/cmd/blcmdl1_tee.htm&quot;&gt;http://linux.about.com/library/cmd/blcmdl1_tee.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.die.net/man/1/tee&quot;&gt;http://linux.die.net/man/1/tee&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.101hacks.com/unix/tee-command-examples/&quot;&gt;http://linux.101hacks.com/unix/tee-command-examples/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Grep : &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/od/commands/l/blcmdl1_grep.htm&quot;&gt;http://linux.about.com/od/commands/l/blcmdl1_grep.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.die.net/man/1/grep&quot;&gt;http://linux.die.net/man/1/grep&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://en.wikipedia.org/wiki/Grep&quot;&gt;https://en.wikipedia.org/wiki/Grep&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Fgrep : &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/library/cmd/blcmdl1_fgrep.htm&quot;&gt;http://linux.about.com/library/cmd/blcmdl1_fgrep.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.die.net/man/1/fgrep&quot;&gt;http://linux.die.net/man/1/fgrep&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.computerhope.com/unix/ufgrep.htm&quot;&gt;http://www.computerhope.com/unix/ufgrep.htm&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Egrep : &lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/library/cmd/blcmdl1_egrep.htm&quot;&gt;http://linux.about.com/library/cmd/blcmdl1_egrep.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.die.net/man/1/egrep&quot;&gt;http://linux.die.net/man/1/egrep&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.101hacks.com/unix/egrep/&quot;&gt;http://linux.101hacks.com/unix/egrep/&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.computerhope.com/unix/uegrep.htm&quot;&gt;http://www.computerhope.com/unix/uegrep.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.hscripts.com/tutorials/linux-commands/egrep.html&quot;&gt;http://www.hscripts.com/tutorials/linux-commands/egrep.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Cut : &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/od/commands/l/blcmdl1_cut.htm&quot;&gt;http://linux.about.com/od/commands/l/blcmdl1_cut.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.computerhope.com/unix/ucut.htm&quot;&gt;http://www.computerhope.com/unix/ucut.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.101hacks.com/linux-commands/cut-command-examples/&quot;&gt;http://linux.101hacks.com/linux-commands/cut-command-examples/&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.hscripts.com/tutorials/linux-commands/cut.html&quot;&gt;http://www.hscripts.com/tutorials/linux-commands/cut.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Wc : &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/library/cmd/blcmdl1_wc.htm&quot;&gt;http://linux.about.com/library/cmd/blcmdl1_wc.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.die.net/man/1/wc&quot;&gt;http://linux.die.net/man/1/wc&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.computerhope.com/unix/uwc.htm&quot;&gt;http://www.computerhope.com/unix/uwc.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/Wc_%28Unix%29&quot;&gt;http://en.wikipedia.org/wiki/Wc_%28Unix%29&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Uniq : &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/library/cmd/blcmdl1_uniq.htm&quot;&gt;http://linux.about.com/library/cmd/blcmdl1_uniq.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/library/cmd/blcmdl_uniq.htm&quot;&gt;http://linux.about.com/library/cmd/blcmdl_uniq.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.die.net/man/1/uniq&quot;&gt;http://linux.die.net/man/1/uniq&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.computerhope.com/unix/uuniq.htm&quot;&gt;http://www.computerhope.com/unix/uuniq.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.101hacks.com/linux-commands/uniq-command-examples/&quot;&gt;http://linux.101hacks.com/linux-commands/uniq-command-examples/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Create a file with the name&lt;i&gt; names&lt;/i&gt;.
&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;File : &lt;i&gt;names&lt;/i&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: text;gutter:false;&quot;&gt;John
Ron
Harry
Maverick
Brown
Aaron
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Commands and Output :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: bash;gutter: false;&quot;&gt;cat names | sort -r
Ron
Maverick
John
Harry
Brown
Aaron

cat names | tee copy
John
Ron
Harry
Maverick
Brown
Aaron

Cat copy
John
Ron
Harry
Maverick
Brown
Aaron

cat names | grep -n &quot;o&quot;
1:John
2:Ron
5:Brown
6:Aaron

cat names | egrep -ni &quot;[ o | h ]&quot;
1:John
2:Ron
3:Harry
5:Brown
6:Aaron

cat names | fgrep -ni &quot;
&amp;gt; rr
&amp;gt; ro
&amp;gt; v&quot;
1:John
2:Ron
3:Harry
4:Maverick
5:Brown
6:Aaron

cat names | wc -lwm
      6       6      35

cat names | uniq -d
cat names | uniq -u
John
Ron
Harry
Maverick
Brown
Aaron

cat names | cut -c1-4
John
Ron
Harr
Mave
Brow
Aaro
&lt;/pre&gt;
&lt;br /&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.
</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/8783344106674354550/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/07/using-filters-in-linux.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/8783344106674354550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/8783344106674354550'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/07/using-filters-in-linux.html' title='Using filters in Linux'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-2440955677596981635</id><published>2013-07-01T00:00:00.000-07:00</published><updated>2013-07-03T11:11:56.813-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Java program based on static members</title><content type='html'>Program to count the number of objects created for a class using static member.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;class Obj{
    static int count;
    Obj(){
        count++;
        System.out.print(&quot;\nObject  &quot;+count+&quot; created...&quot;);
    }
    static void showCount(){
        System.out.print(&quot;\nTotal Object Count  :  &quot;+count);
    }
}
class ObjCount{
    public static void main(String args[]){
        Obj o1=new Obj();
        Obj o2=new Obj();
        Obj.showCount();
        Obj o3=new Obj();
        Obj.showCount();
    }  
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: text;gutter: false;&quot;&gt;Object  1 created...
Object  2 created...
Total Object Count  :  2
Object  3 created...
Total Object Count  :  3
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/2440955677596981635/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/07/java-program-based-on-static-members.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/2440955677596981635'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/2440955677596981635'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/07/java-program-based-on-static-members.html' title='Java program based on static members'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-8718466123203542311</id><published>2013-06-30T00:00:00.000-07:00</published><updated>2013-07-03T11:11:33.081-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Java program to sort a given array</title><content type='html'>Java program to sort a given array.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;class Array{
    int a[]={9,7,4,-1,0};
    voidsortArray(){
    int i,j,temp;
    for(i=0;i&amp;lt;a.length;i++){
        for(j=0;j&amp;lt;a.length-1;j++){
            if(a[j]&amp;gt;a[j+1]){
                    temp=a[j];
                    a[j]=a[j+1];
                    a[j+1]=temp;
                }
            }
        }
    }
    voidshowArray(){
        for(inti=0;i&amp;lt;a.length;i++){
            System.out.print(&quot; a[&quot;+i+&quot;] : &quot;+a[i]+&quot;\t&quot;);
        }
    }
}
class Sort{
    public static void main(String args[]){
        Array t=new Array();
        System.out.print(&quot;\n Array Elements : \n &quot;);
        t.showArray();
        System.out.print(&quot;\n Sorted Array Elements : \n &quot;);
        t.sortArray();
        t.showArray();
    }
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: text;gutter: false;&quot;&gt;Array Elements :
  a[0] : 9       a[1] : 7        a[2] : 4        a[3] : -1       a[4] : 0

 Sorted Array Elements :
  a[0] : -1      a[1] : 0        a[2] : 4        a[3] : 7        a[4] : 9
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/8718466123203542311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/java-program-to-sort-given-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/8718466123203542311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/8718466123203542311'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/java-program-to-sort-given-array.html' title='Java program to sort a given array'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-1029581648100026487</id><published>2013-06-29T00:00:00.000-07:00</published><updated>2013-06-29T00:00:09.136-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Java program based on constructor</title><content type='html'>Program to keep record of height and weight of people.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;import java.io.*;
class Person{
    float height;
    float weight;
    Person(float h,float w){
        height=h;
        weight=w;
    }
    void putPersonData(){
        System.out.print(&quot;\nHeight : &quot;+height+&quot; Weight : &quot;+weight);
    }
};
class PersonCount{
    static int count;
    static Person p[]=new Person[10];
    static void showCount(){
        for(int i=0;i&amp;lt;10;i++){
            p[i].putPersonData();
            if(p[i].height&amp;gt;170 &amp;amp;&amp;amp; p[i].weight&amp;lt;50){
                count=count+1;            
            }
        }
        System.out.print(&quot;\n\nTotal Count (weight&amp;lt;50kg AND height&amp;gt;170cm ) : &quot;+count+&quot;\n&quot;);
    }
    public static void main(String args[]){
        p[0]=new Person(173,40);
        p[1]=new Person(170,30);
        p[2]=new Person(168,55); 
        p[3]=new Person(172,55);
        p[4]=new Person(169,55);
        p[5]=new Person(175,70);
        p[6]=new Person(171,45);
        p[7]=new Person(172,55);
        p[8]=new Person(168,55);
        p[9]=new Person(168,65);
        showCount();
    }
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: text;gutter: false;&quot;&gt;Height : 173.0 Weight : 40.0
Height : 170.0 Weight : 30.0
Height : 168.0 Weight : 55.0
Height : 172.0 Weight : 55.0
Height : 169.0 Weight : 55.0
Height : 175.0 Weight : 70.0
Height : 171.0 Weight : 45.0
Height : 172.0 Weight : 55.0
Height : 168.0 Weight : 55.0
Height : 168.0 Weight : 65.0

Total Count (weight&amp;lt;50kg AND height&amp;gt;170cm ) : 2
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Program to maintain score card of students.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: java;&quot;&gt;import java.io.*;
class Student{
    String name;
    Student(String nm){
        name=nm;
    }
    void putStudentName(){
        System.out.print(&quot;\n Student Name : &quot;+name);
    }
};
class Marks{
    Student s;
    int mark1,mark2;
    Marks(String name,int m1,int m2){
        s=new Student(name);
        mark1=m1;
        mark2=m2;
    }
    void putmarks(){
        s.putStudentName();
        System.out.print(&quot;\nMark 1 : &quot;+mark1);
        System.out.print(&quot;\nMark 2 : &quot;+mark2);
        putAverage();  
    } 
    void putAverage(){
        float t=(mark1+mark2)/(float)2;
        System.out.print(&quot;\nAverage : &quot;+t);
    } 
};
class Result{
    public static void main(String args[]){
        Marks m=new Marks(&quot;Maverick&quot;,80,85);
        m.putmarks();
    }
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: text;gutter: false;&quot;&gt;Student Name : Maverick
Mark 1 : 80
Mark 2 : 85
Average : 82.5
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/1029581648100026487/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/java-program-based-on-constructor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/1029581648100026487'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/1029581648100026487'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/java-program-based-on-constructor.html' title='Java program based on constructor'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-3919419451291170323</id><published>2013-06-26T00:00:00.000-07:00</published><updated>2013-06-27T12:44:25.976-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><title type='text'>C++ program to print a checkboard (8-by-8 grid)</title><content type='html'>Print a checkboard (8-by-8 grid). Each square should be 5-by-2 characters wide. A 2-by-2 example follows:&lt;br /&gt;
&lt;pre class=&quot;brush: text;gutter:false;&quot;&gt;
+-----+-----+
|     |     |
|     |     |
+-----+-----+
|     |     |
|     |     |
+-----+-----+
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Code :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: cpp;&quot;&gt;#include &amp;lt;iostream.h&amp;gt;
#include &amp;lt;conio.h&amp;gt;
void main()
{
    int i,j,k,l;
    clrscr();
    for(i=0;i&amp;lt;9;i++)
    {
        for(j=0;j&amp;lt;8;j++)
        {
            cout&amp;lt;&amp;lt;&quot;+&quot;;
            for(k=0;k&amp;lt;5;k++)
            {
                cout&amp;lt;&amp;lt;&quot;-&quot;;
            }
        }
        cout&amp;lt;&amp;lt;&quot;+&quot;&amp;lt;&amp;lt;endl;
        if(i&amp;lt;8)
        {
            for(l=0;l&amp;lt;2;l++)
            {
                for(j=0;j&amp;lt;9;j++)
                {
                    for(k=0;k&amp;lt;2;k++)
                    {
                        if(k%5==0)
                            cout&amp;lt;&amp;lt;&quot;|     &quot;;
                    }
                }
                cout&amp;lt;&amp;lt;endl;
            }
        }
    }
    getch();
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:text;gutter: false;&quot;&gt;+-----+-----+-----+-----+-----+-----+-----+-----+
|     |     |     |     |     |     |     |     |
|     |     |     |     |     |     |     |     |
+-----+-----+-----+-----+-----+-----+-----+-----+
|     |     |     |     |     |     |     |     |
|     |     |     |     |     |     |     |     |
+-----+-----+-----+-----+-----+-----+-----+-----+
|     |     |     |     |     |     |     |     |
|     |     |     |     |     |     |     |     |
+-----+-----+-----+-----+-----+-----+-----+-----+
|     |     |     |     |     |     |     |     |
|     |     |     |     |     |     |     |     |
+-----+-----+-----+-----+-----+-----+-----+-----+
|     |     |     |     |     |     |     |     |
|     |     |     |     |     |     |     |     |
+-----+-----+-----+-----+-----+-----+-----+-----+
|     |     |     |     |     |     |     |     |
|     |     |     |     |     |     |     |     |
+-----+-----+-----+-----+-----+-----+-----+-----+
|     |     |     |     |     |     |     |     |
|     |     |     |     |     |     |     |     |
+-----+-----+-----+-----+-----+-----+-----+-----+
|     |     |     |     |     |     |     |     |
|     |     |     |     |     |     |     |     |
+-----+-----+-----+-----+-----+-----+-----+-----+

&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; The program above has been tested using TurboCPP. Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/3919419451291170323/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-to-print-checkboard-8-by-8.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/3919419451291170323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/3919419451291170323'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-to-print-checkboard-8-by-8.html' title='C++ program to print a checkboard (8-by-8 grid)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-2563308192362106863</id><published>2013-06-25T00:00:00.000-07:00</published><updated>2013-06-26T23:49:29.622-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Shell script"/><title type='text'>Shell script to rename files based on suffix</title><content type='html'>Given below is a Shell script to rename files based on suffix.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Links that you may find important : &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/od/commands/l/blcmdl1_ls.htm&quot;&gt;http://linux.about.com/od/commands/l/blcmdl1_ls.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/Ls&quot;&gt;http://en.wikipedia.org/wiki/Ls&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/library/cmd/blcmdl1_wc.htm&quot;&gt;http://linux.about.com/library/cmd/blcmdl1_wc.htm&lt;/a&gt;&lt;span id=&quot;goog_1101447801&quot;&gt;&lt;/span&gt;&lt;a href=&quot;https://www.blogger.com/&quot;&gt;&lt;/a&gt;&lt;span id=&quot;goog_1101447802&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.computerhope.com/unix/uwc.htm&quot;&gt;http://www.computerhope.com/unix/uwc.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/Wc_%28Unix%29&quot;&gt;http://en.wikipedia.org/wiki/Wc_%28Unix%29&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/Cut_%28Unix%29&quot;&gt;http://en.wikipedia.org/wiki/Cut_%28Unix%29&lt;/a&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;a href=&quot;http://linux.about.com/od/commands/l/blcmdl1_cut.htm&quot;&gt;http://linux.about.com/od/commands/l/blcmdl1_cut.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/library/cmd/blcmdln_expr.htm&quot;&gt;http://linux.about.com/library/cmd/blcmdln_expr.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/Expr&quot;&gt;http://en.wikipedia.org/wiki/Expr&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: bash;&quot;&gt;#!/bin/sh 
if [ $# -ne 2 ]
then
    echo &quot;Please enter 2 arguments&quot;
    exit
fi

echo &quot;files with suffix $1&quot;
ls *$1
suffix_len=`echo $1|wc -c`
echo &quot;suffix length = $suffix_len&quot;
filelist=`ls *$1`
echo $filelist
num_of_files=`echo $filelist| wc -w`
echo $num_of_files

c=1
while [ $c -le $num_of_files ]
do
    file_name=`echo $filelist| cut -d&quot; &quot; -f$c`
    echo &quot;File Name = $file_name&quot;
    file_len=`echo $file_name| wc -c`
    echo &quot;Filename Length = $file_len&quot;
    n=`expr $file_len - $suffix_len`
    echo &quot;n = $n&quot;
    file_prefix=`echo $file_name| cut -c1-$n`
    echo &quot;Prefix of File = $file_prefix&quot;
    mv $file_name $file_prefix$2
    c=`expr $c + 1`
done
filelist=`ls *$1`
echo $filelist
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: text;gutter: false;&quot;&gt;files with suffix txt
a.txt btxt ctxt
suffix length = 4
a.txt btxt txt
3
File Name = a.txt
Filename Length = 6
n = 2
Prefix of File = a.
File Name = btxt
Filename Length = 5
n = 1
Prefix of File = b
File Name = ctxt
Filename Length = 5
n = 1
Prefix of File=c
a.text btext ctext
&lt;/pre&gt;
&lt;br /&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.
</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/2563308192362106863/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/shell-script-to-rename-files-based-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/2563308192362106863'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/2563308192362106863'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/shell-script-to-rename-files-based-on.html' title='Shell script to rename files based on suffix'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-3962148328787470544</id><published>2013-06-24T00:00:00.000-07:00</published><updated>2013-06-26T00:22:00.039-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><title type='text'>C++ program to find a binary equivalent of a number using recursion</title><content type='html'>Given below is a C++ Program to find a binary equivalent of a number using recursion.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Example :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
2 / 14 = 7 Quotient | 0 Remainder&lt;br /&gt;
2 / 7 = 3 Quotient | 1 Remainder&lt;br /&gt;
2 / 3 = 1 Quotient | 1 Remainder&lt;br /&gt;
2 / 1 = 0 Quotient | 1 Remainder&lt;br /&gt;
&lt;br /&gt;
Now take all the Remainder in reverse order. Now we have 14 = 1110&lt;sub&gt;2&lt;/sub&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;b class=&quot;normal&quot;&gt;Links that you may find important :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://en.wikipedia.org/wiki/Binary_number&quot;&gt;https://en.wikipedia.org/wiki/Binary_number&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.mathsisfun.com/binary-number-system.html&quot;&gt;http://www.mathsisfun.com/binary-number-system.html&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://acc6.its.brooklyn.cuny.edu/~gurwitz/core5/nav2tool.html&quot;&gt;http://acc6.its.brooklyn.cuny.edu/~gurwitz/core5/nav2tool.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: cpp;&quot;&gt;#include &amp;lt;iostream.h&amp;gt;
#include &amp;lt;conio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#define range 8
char a[range]=&quot;00000000&quot;;
int count;
void binary(int no,int count)
{
 if(no!=0)
 {
  int k;
  k=no%2;
  no=no/2;
  if(k==0)
  a[count]=48;
  if(k==1)
  a[count]=49;
  binary(no,count+1);
 }
}
void main()
{
 int no;
 clrscr();
 cout&amp;lt;&amp;lt;&quot;Enter number to be converted to binary : &quot;;
 cin&amp;gt;&amp;gt;no;
 binary(no,0);
 strrev(a);
 cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;a;
 getch();
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:text;gutter: false;&quot;&gt;Enter number to be converted to binary : 127

01111111
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; The program above has been tested using TurboCPP. Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/3962148328787470544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-to-find-binary-equivalent-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/3962148328787470544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/3962148328787470544'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-to-find-binary-equivalent-of.html' title='C++ program to find a binary equivalent of a number using recursion'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-3527603081301857462</id><published>2013-06-22T00:00:00.000-07:00</published><updated>2013-06-26T23:39:45.744-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Shell script"/><title type='text'>Shell scripting using general-purpose utilities - Menu driven program</title><content type='html'>Given below is a menu driven shell script which will print the following menu and execute the given task to display result on standard output.&lt;br /&gt;
MENU&lt;br /&gt;
1 Display calendar of current month&lt;br /&gt;
2 Display today’s date and time&lt;br /&gt;
3 Display usernames those are currently logged in the system&lt;br /&gt;
4 Display current directory&lt;br /&gt;
5 Display your terminal number&lt;br /&gt;
6 Exit
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Links that you may find important : &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Calender [cal] :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/library/cmd/blcmdl1_cal.htm&quot;&gt;http://linux.about.com/library/cmd/blcmdl1_cal.htm&lt;/a&gt;
&lt;a href=&quot;http://www.hscripts.com/tutorials/linux-commands/cal.html&quot;&gt;http://www.hscripts.com/tutorials/linux-commands/cal.html&lt;/a&gt;
&lt;a href=&quot;http://www.computerhope.com/unix/ucal.htm&quot;&gt;http://www.computerhope.com/unix/ucal.htm&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Date [date] :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/od/commands/l/blcmdl1_date.htm&quot;&gt;http://linux.about.com/od/commands/l/blcmdl1_date.htm&lt;/a&gt;

&lt;a href=&quot;http://www.computerhope.com/unix/udate.htm&quot;&gt;http://www.computerhope.com/unix/udate.htm&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Who is logged on [who] : &lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/library/cmd/blcmdl1_who.htm&quot;&gt;http://linux.about.com/library/cmd/blcmdl1_who.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.computerhope.com/unix/uwho.htm&quot;&gt;http://www.computerhope.com/unix/uwho.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.ibm.com/developerworks/community/blogs/58e72888-6340-46ac-b488-d31aa4058e9c/entry/linux_who_command_with_examples61?lang=en&quot;&gt;https://www.ibm.com/developerworks/community/blogs/58e72888-6340-46ac-b488-d31aa4058e9c/entry/linux_who_command_with_examples61?lang=en&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Current working directory [pwd] : &lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/library/cmd/blcmdl1_pwd.htm&quot;&gt;http://linux.about.com/library/cmd/blcmdl1_pwd.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.die.net/man/1/pwd&quot;&gt;http://linux.die.net/man/1/pwd&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Terminal [tty] :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://linux.about.com/od/commands/l/blcmdl4_tty.htm&quot;&gt;http://linux.about.com/od/commands/l/blcmdl4_tty.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://linux.die.net/man/1/tty&quot;&gt;http://linux.die.net/man/1/tty&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: bash;&quot;&gt;echo &quot;Menu&quot;
echo &quot;Press 1 to display calendar of current month&quot; 
echo &quot;Press 2 to display todays date and time&quot;
echo &quot;Press 3 to display usernames that are currently logged into the system&quot;
echo &quot;Press 4 to display current directory&quot;
echo &quot;Press 5 to display your terminal number&quot;
echo &quot;Press 6 to Exit&quot;
echo &quot;Enter your choice : &quot;
read n
case $n in
1)
cal;;
2)
date;;
3)
who;;
4)
pwd;;
5)
tty;;
6)
exit;;
esac
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: text;gutter: false;&quot;&gt;Menu
Press 1 to display calendar of current month
Press 2 to display todays date and time
Press 3 to display usernames that are currently logged into the system
Press 4 to display current directory
Press 5 to display your terminal number
Press 6 to Exit
Enter your choice : 
1
   February 2012      
Su  Mo Tu  We Th  Fr  Sa  
                 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           
                  
Menu
Press 1 to display calender of current month
Press 2 to display todays date and time
Press 3 to display usernames that are currently logged into the system
Press 4 to display current directory
Press 5 to deisplay your terminal number
Press 6 to Exit
Enter your choice : 
2
Mon Feb 20 10:56:40 IST 2012

Menu
Press 1 to display calender of current month
Press 2 to display todays date and time
Press 3 to display usernames that are currently logged into the system
Press 4 to display current directory
Press 5 to deisplay your terminal number
Press 6 to Exit
Enter your choice : 
3
john     pts/0        2012-02-20 10:28 (:0.0)

Menu
Press 1 to display calendar of current month
Press 2 to display todays date and time
Press 3 to display usernames that are currently logged into the system
Press 4 to display current directory
Press 5 to displays your terminal number
Press 6 to Exit
Enter your choice : 
4
/home/john/Linux/Prac3

Menu
Press 1 to display calender of current month
Press 2 to display todays date and time
Press 3 to display usernames that are currently logged into the system
Press 4 to display current directory
Press 5 to deisplay your terminal number
Press 6 to Exit
Enter your choice : 
5
/dev/pts/0
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.
</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/3527603081301857462/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/shell-scripting-using-general-purpose.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/3527603081301857462'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/3527603081301857462'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/shell-scripting-using-general-purpose.html' title='Shell scripting using general-purpose utilities - Menu driven program'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-1410738119179017311</id><published>2013-06-20T00:00:00.000-07:00</published><updated>2013-07-14T11:41:35.905-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="Computer Graphics"/><title type='text'>Character generation in C using Bitmap method</title><content type='html'>Given below is a C program for character generation using Bitmap method.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Links that you may find important :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span id=&quot;goog_1407950128&quot;&gt;&lt;/span&gt;&lt;a href=&quot;http://www.blogger.com/&quot;&gt;&lt;/a&gt;&lt;span id=&quot;goog_1407950129&quot;&gt;&lt;/span&gt;&lt;a href=&quot;http://books.google.co.in/books?id=iJUvWG59zvkC&amp;amp;pg=SA1-PA54&amp;amp;lpg=SA1-PA54&amp;amp;dq=character+generation+bitmap+computer+graphics&amp;amp;source=bl&amp;amp;ots=_2DZ7DesjG&amp;amp;sig=Nmvwzd2BERrLPq-fEkVw_9obA7Q&amp;amp;hl=en&amp;amp;sa=X&amp;amp;ei=blq_UaOOMcuPrgeA_ICABw&amp;amp;redir_esc=y#v=onepage&amp;amp;q=character%20generation%20bitmap%20computer%20graphics&amp;amp;f=false&quot;&gt;Computer Graphics And Multimedia  By A.P.Godse, D.A.Godse&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c; tab-size: 8; smart-tabs: false;highlight:[3,7,49,50,82]&quot;&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;conio.h&amp;gt;
#include &amp;lt;graphics.h&amp;gt;
void main()
{
    int i,j,k,x,y;
    int gd=DETECT,gm;//DETECT is macro defined in graphics.h
    /* ch1 ch2 ch3 ch4 are character arrays that display alphabets */
    int ch1[][10]={ {1,1,1,1,1,1,1,1,1,1},
                    {1,1,1,1,1,1,1,1,1,1},
                    {0,0,0,0,1,1,0,0,0,0},
                    {0,0,0,0,1,1,0,0,0,0},
                    {0,0,0,0,1,1,0,0,0,0},
                    {0,0,0,0,1,1,0,0,0,0},
                    {0,0,0,0,1,1,0,0,0,0},
                    {0,1,1,0,1,1,0,0,0,0},
                    {0,1,1,0,1,1,0,0,0,0},
                    {0,0,1,1,1,0,0,0,0,0}};
    int ch2[][10]={ {0,0,0,1,1,1,1,0,0,0},
                    {0,0,1,1,1,1,1,1,0,0},
                    {1,1,0,0,0,0,0,0,1,1},
                    {1,1,0,0,0,0,0,0,1,1},
                    {1,1,0,0,0,0,0,0,1,1},
                    {1,1,0,0,0,0,0,0,1,1},
                    {1,1,0,0,0,0,0,0,1,1},
                    {1,1,0,0,0,0,0,0,1,1},
                    {0,0,1,1,1,1,1,1,0,0},
                    {0,0,0,1,1,1,1,0,0,0}};
    int ch3[][10]={ {1,1,0,0,0,0,0,0,1,1},
                    {1,1,0,0,0,0,0,0,1,1},
                    {1,1,0,0,0,0,0,0,1,1},
                    {1,1,0,0,0,0,0,0,1,1},
                    {1,1,1,1,1,1,1,1,1,1},
                    {1,1,1,1,1,1,1,1,1,1},
                    {1,1,0,0,0,0,0,0,1,1},
                    {1,1,0,0,0,0,0,0,1,1},
                    {1,1,0,0,0,0,0,0,1,1},
                    {1,1,0,0,0,0,0,0,1,1}};
    int ch4[][10]={ {1,1,0,0,0,0,0,0,1,1},
                    {1,1,1,1,0,0,0,0,1,1},
                    {1,1,0,1,1,0,0,0,1,1},
                    {1,1,0,1,1,0,0,0,1,1},
                    {1,1,0,0,1,1,0,0,1,1},
                    {1,1,0,0,1,1,0,0,1,1},
                    {1,1,0,0,0,1,1,0,1,1},
                    {1,1,0,0,0,1,1,0,1,1},
                    {1,1,0,0,0,0,1,1,1,1},
                    {1,1,0,0,0,0,0,0,1,1}};
    initgraph(&amp;amp;gd,&amp;amp;gm,&quot;D:\\TC\\BGI&quot;);//initialize graphic mode
    setbkcolor(LIGHTGRAY);//set color of background to darkgray
    for(k=0;k&amp;lt;4;k++)
    { 
        for(i=0;i&amp;lt;10;i++)
        {
            for(j=0;j&amp;lt;10;j++)
            {
                if(k==0)
                { 
                    if(ch1[i][j]==1)
                    putpixel(j+250,i+230,RED);
                }
                if(k==1)
                { 
                    if(ch2[i][j]==1)
                    putpixel(j+300,i+230,RED);
                }
                if(k==2)
                { 
                    if(ch3[i][j]==1)
                    putpixel(j+350,i+230,RED);
                }
                if(k==3)
                { 
                    if(ch4[i][j]==1)
                    putpixel(j+400,i+230,RED);
                }
            }
            delay(200);
        }
    }
    getch();
    closegraph();
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFNcHluic8Cmz0vZT_hhKIlJNJbx7roFSPtNam1rSABXI2HRM9mQeNOipux1G1OaTHfMbvE54TfVrpg4v_9xcIgon6VoMLSf_89z_67ID3f4zN-R3RKCurm_LKCciyhQnm7kqW_GrXZ5c/s1600/CHARACTER+GENERATION.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFNcHluic8Cmz0vZT_hhKIlJNJbx7roFSPtNam1rSABXI2HRM9mQeNOipux1G1OaTHfMbvE54TfVrpg4v_9xcIgon6VoMLSf_89z_67ID3f4zN-R3RKCurm_LKCciyhQnm7kqW_GrXZ5c/s320/CHARACTER+GENERATION.jpg&quot; height=&quot;253&quot; style=&quot;background: none; border: none; box-shadow: none;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; The program above has been tested using TurboCPP. Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.
</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/1410738119179017311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/character-generation-in-c-using-bitmap.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/1410738119179017311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/1410738119179017311'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/character-generation-in-c-using-bitmap.html' title='Character generation in C using Bitmap method'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFNcHluic8Cmz0vZT_hhKIlJNJbx7roFSPtNam1rSABXI2HRM9mQeNOipux1G1OaTHfMbvE54TfVrpg4v_9xcIgon6VoMLSf_89z_67ID3f4zN-R3RKCurm_LKCciyhQnm7kqW_GrXZ5c/s72-c/CHARACTER+GENERATION.jpg" height="72" width="72"/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-8264899036241861094</id><published>2013-06-19T00:00:00.000-07:00</published><updated>2013-09-26T11:13:53.991-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><title type='text'>C program to convert temperature from Celsius to Fahrenheit</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Given below is a C program to convert temperature from Celsius to Fahrenheit.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Formula to convert Celsius to Fahrenheit :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Multiply by 9, then divide by 5, then add 32&lt;br /&gt;
&lt;br /&gt;
°C x 9/5 + 32 = °F&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Formula to convert Fahrenheit to Celsius :&lt;/b&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
Deduct 32, then multiply by 5, then divide by 9&lt;br /&gt;
&lt;br /&gt;
((°F  -  32)  x  5) / 9 = °C&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Example :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
0°C = 32°F&lt;br /&gt;
&lt;br /&gt;
22°C = 77°F&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Links that you may find important :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/Celsius&quot;&gt;http://en.wikipedia.org/wiki/Celsius&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/Fahrenheit&quot;&gt;http://en.wikipedia.org/wiki/Fahrenheit&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.mathsisfun.com/temperature-conversion.html&quot;&gt;http://www.mathsisfun.com/temperature-conversion.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c; tab-size: 8; smart-tabs: false;highlight:[9]&quot;&gt;#include &amp;lt;conio.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
void main()
{
 float cent,faren;
 clrscr();
 printf(&quot;Enter the temperature in Celsius : &quot;);
 scanf(&quot;%f&quot;,&amp;amp;cent);
 faren=cent*9.0/5.0+32.0;
 printf(&quot;\nTemperature in Fahrenheit : %6.2f&quot;,faren);//.2f prints only 2 digits after decimal
 getch();
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: text; gutter: false;&quot;&gt;Enter the temperature in Celsius : 25

Temperature in Fahrenheit :  77.00
&lt;/pre&gt;
The above program can be modified to convert Fahrenheit to Celsius.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c; tab-size: 8; smart-tabs: false;highlight:[9];&quot;&gt;#include &amp;lt;conio.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
void main()
{
 float cent,faren;
 clrscr();
 printf(&quot;Enter the temperature in Fahrenheit : &quot;);
 scanf(&quot;%f&quot;,&amp;amp;faren);
 cent=((faren-32.0)*5.0)/9.0;
 printf(&quot;\nTemperature in Celsius : %6.2f&quot;,cent);//.2f prints only 2 digits after decimal
 getch();
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: text; gutter: false;&quot;&gt;Enter the temperature in Fahrenheit : 25

Temperature in Celsius :  77.00
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; The program above has been tested using TurboCPP. Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/8264899036241861094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-to-convert-temperature-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/8264899036241861094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/8264899036241861094'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-to-convert-temperature-from.html' title='C program to convert temperature from Celsius to Fahrenheit'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-2664310507300516404</id><published>2013-06-18T00:00:00.000-07:00</published><updated>2013-07-14T11:36:32.667-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Java program to swap two numbers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Given below is a Java program to swap two numbers.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: java;highlight:[18]&quot;&gt;// Class Swap
class Swap{
    // method swap 
    void swap(int num1,int num2){
        num1 = num1 + num2;
        num2 = num1 - num2;
        num1 = num1 - num2;
        System.out.println(&quot;After swapping\nNumber 1= &quot; + num1 + &quot; and Number 2= &quot;+ num2);
    }
}
// Class SwapDemo 
class SwapDemo{
    public static void main(String[] args) {
        int num1=10,num2=20;
        System.out.println(&quot;Number 1: &quot;+num1);
        System.out.println(&quot;Number 2: &quot;+num2);
        Swap s=new Swap();
        s.swap(num1,num2);//call to the swap method
    }
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: text;gutter: false;&quot;&gt;Number 1: 10
Number 2: 20
After swapping
Number 1= 20 and Number 2= 10
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/2664310507300516404/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/java-program-to-swap-two-numbers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/2664310507300516404'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/2664310507300516404'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/java-program-to-swap-two-numbers.html' title='Java program to swap two numbers'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-6013893613007305579</id><published>2013-06-16T00:00:00.000-07:00</published><updated>2013-07-14T10:55:01.413-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="Computer Graphics"/><title type='text'>C Program for Bresenham’s Line Drawing Algorithm</title><content type='html'>Given below is a C program to draw a line using Bresenham’s Line Drawing Algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;
#include&amp;lt;graphics.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;
void draw(int x1,int y1,int x2,int y2);
void main() 
{
    int x1,x2,y1,y2;
    int gd=DETECT,gm;//DETECT is macro defined in graphics.h
    initgraph(&amp;amp;gd,&amp;amp;gm,&quot;d:\\tc\\bgi&quot;);//initialize graphic mode
    printf(&quot;Enter values of x1 and y1: &quot;);
    scanf(&quot;%d %d&quot;,&amp;amp;x1,&amp;amp;y1);
    printf(&quot;Enter values of x2 and y2 : &quot;);
    scanf(&quot;%d %d&quot;,&amp;amp;x2,&amp;amp;y2);
    draw(x1,y1,x2,y2);//call to function that draws the line
    getch();
}
void draw(int x1,int y1,int x2,int y2)
{
    float dx,dy,p;
    int i,x,y,xend;
    dx=x2-x1;
    dy=y2-y1;
    p=2*dy-dx;
    if(x1&amp;gt;x2)
    {
        x-x2;
        y=y2;
        xend=x1;
    }
    else
    {
        x=x1;
        y=y1;
        xend=x2;
    }
    putpixel(x,y,10);
    while(x&amp;lt;xend)
    {
        if(p&amp;lt;0)
        {
            x=x+1;
            putpixel(x,y,10);
            p=p+(2*dy);
        }
        else
        {
            x=x+1;
            y=y+1;
            putpixel(x,y,10);
            p=p+(2*dy)-(2*dx);
        }
    }
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg44aoT-y-JM4c_eqMVTUNCmBw-0nrmHCksfVrisB7306DlWg12vZDU1aR_hohBnMK5P2QJXuuaQ7qc-N7Y8QO5mh-QMYcaYKl3foH4dADfCj2JMzs6oAN60-So0v4Z1jgPLjVtKUE1a_U/s1600/BRESENHAMS.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg44aoT-y-JM4c_eqMVTUNCmBw-0nrmHCksfVrisB7306DlWg12vZDU1aR_hohBnMK5P2QJXuuaQ7qc-N7Y8QO5mh-QMYcaYKl3foH4dADfCj2JMzs6oAN60-So0v4Z1jgPLjVtKUE1a_U/s1600/BRESENHAMS.jpg&quot; height=&quot;253&quot; style=&quot;background: none; border: none; box-shadow: none;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; In the above screenshot the line is hardly visible. The image above is a grayscale of original image.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; The program above has been tested using TurboCPP. Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/6013893613007305579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-for-bresenhams-line-drawing.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/6013893613007305579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/6013893613007305579'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-for-bresenhams-line-drawing.html' title='C Program for Bresenham’s Line Drawing Algorithm'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg44aoT-y-JM4c_eqMVTUNCmBw-0nrmHCksfVrisB7306DlWg12vZDU1aR_hohBnMK5P2QJXuuaQ7qc-N7Y8QO5mh-QMYcaYKl3foH4dADfCj2JMzs6oAN60-So0v4Z1jgPLjVtKUE1a_U/s72-c/BRESENHAMS.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-4016805731487260420</id><published>2013-06-15T23:29:00.000-07:00</published><updated>2013-07-14T11:01:55.697-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="Computer Graphics"/><title type='text'>C Program for DDA (graphics algorithm)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Given below is a C program to draw a line using DDA algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;
#include&amp;lt;graphics.h&amp;gt;
#include&amp;lt;math.h&amp;gt;
int sign(int nd)
{
    if(nd&amp;gt;0)
        return +1;
    else if(nd&amp;lt;0)
        return -1;
    else
        return 0;
}
void main()
{
    int gd=DETECT,gm,i=1,j;//DETECT is macro defined in graphics.h
    int x1,x2,y1,y2,length;
    float dx,dy,ndx,ndy,x,y;
    initgraph(&amp;amp;gd,&amp;amp;gm,&quot;d:\\tc\\bgi&quot;);//initialize graphic mode
    setbkcolor(DARKGRAY);//set the background color
    printf(&quot;Enter x1:&quot;);
    scanf(&quot;%d&quot;,&amp;amp;x1);
    printf(&quot;Enter y1:&quot;);
    scanf(&quot;%d&quot;,&amp;amp;y1);
    printf(&quot;Enter x2:&quot;);
    scanf(&quot;%d&quot;,&amp;amp;x2);
    printf(&quot;Enter y2:&quot;);
    scanf(&quot;%d&quot;,&amp;amp;y2);
    dx=x2-x1;
    dy=y2-y1;
    if(abs(dx)&amp;gt;=abs(dy))
        length=abs(dx);
    else
        length=abs(dy);
    ndx=dx/length;
    ndy=dy/length;
    x=x1+(0.5*sign(ndx));
    y=y1+(0.5*sign(ndy));
    while(i&amp;lt;=length)
    {
        putpixel(x,y,4);
        x=x+ndx;
        y=y+ndy;
        i=i+1;
    }
    getch();
    closegraph();
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_CLnriR1cFghjRblNGTb4QjsR-wUYae3LQBf39M5t_HFaqOgfb7AAILDauhPIf35hZypNYJxvZaRpLRtpp5p9uLGtnD8326pz_ZHz1g392p8YzIURb_ZPJa9-kRnwrGckgWL4nxG-6yQ/s1600/DDA.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;253&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_CLnriR1cFghjRblNGTb4QjsR-wUYae3LQBf39M5t_HFaqOgfb7AAILDauhPIf35hZypNYJxvZaRpLRtpp5p9uLGtnD8326pz_ZHz1g392p8YzIURb_ZPJa9-kRnwrGckgWL4nxG-6yQ/s1600/DDA.jpg&quot; style=&quot;background: none; border: none; box-shadow: none;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; In the above screenshot the line is hardly visible. The image above is a grayscale of original image.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; The program above has been tested using TurboCPP. Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/4016805731487260420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-for-dda-graphics-algorithm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/4016805731487260420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/4016805731487260420'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-for-dda-graphics-algorithm.html' title='C Program for DDA (graphics algorithm)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_CLnriR1cFghjRblNGTb4QjsR-wUYae3LQBf39M5t_HFaqOgfb7AAILDauhPIf35hZypNYJxvZaRpLRtpp5p9uLGtnD8326pz_ZHz1g392p8YzIURb_ZPJa9-kRnwrGckgWL4nxG-6yQ/s72-c/DDA.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-3871873274657087235</id><published>2013-06-14T00:00:00.001-07:00</published><updated>2013-07-14T10:52:00.337-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="Shell script"/><title type='text'>Shell script to display prime numbers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Bash script to display prime numbers.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Links that you may find important : &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://en.wikipedia.org/wiki/Prime_number&quot;&gt;https://en.wikipedia.org/wiki/Prime_number&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_prime_numbers&quot;&gt;http://en.wikipedia.org/wiki/List_of_prime_numbers&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/2_%28number%29&quot;&gt;http://en.wikipedia.org/wiki/2_%28number%29&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: bash;&quot;&gt;echo &#39;Enter no&#39;
read x
n=2
while [ $n -le $x ]
do
i=2
count=1

while [ $i -lt $n ]
do
if [ `expr $n % $i` -eq 0 ]
then
count=0
break
fi
i=`expr $i + 1`
done

if [ $count -eq 1 ]
then
echo &quot;$n is Prime&quot;
fi

n=`expr $n + 1`
done
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: text;gutter: false;&quot;&gt;2 is Prime
3 is Prime
5 is Prime
7 is Prime
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/3871873274657087235/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/shell-script-to-display-prime-numbers.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/3871873274657087235'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/3871873274657087235'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/shell-script-to-display-prime-numbers.html' title='Shell script to display prime numbers'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-5807776695441393293</id><published>2013-06-13T00:00:00.000-07:00</published><updated>2013-07-14T10:51:16.972-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><title type='text'>C program to implement Insertion sort</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Given below is a C program to implement Insertion sort.&lt;br /&gt;
What is Insertion sort? &lt;a href=&quot;http://en.wikipedia.org/wiki/Insertion_sort&quot;&gt;Click here to read about it.&lt;/a&gt;&lt;br /&gt;
In Insertion sort the element is positioned at its proper place by inserting it and shifting the other elements to the right. The elements are sorted in increasing order of their position.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Example :&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: text; gutter: false;&quot;&gt;75 35 47 15

Pass 0 : 75 35 47 15
Pass 1 : 35 75 47 15
Pass 2 : 35 47 75 15
Pass 3 : 15 35 47 75

&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Links that you may find important :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.sorting-algorithms.com/insertion-sort&quot;&gt;http://www.sorting-algorithms.com/insertion-sort&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.algolist.net/Algorithms/Sorting/Insertion_sort&quot;&gt;http://www.algolist.net/Algorithms/Sorting/Insertion_sort&lt;/a&gt;
&lt;br /&gt;
&lt;a href=&quot;https://www.youtube.com/watch?v=c4BRHC7kTaQ&quot;&gt;https://www.youtube.com/watch?v=c4BRHC7kTaQ&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.youtube.com/watch?v=Kg4bqzAqRBM&quot;&gt;https://www.youtube.com/watch?v=Kg4bqzAqRBM&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c; tab-size: 8; smart-tabs: false;highlight:[14,16,35];&quot;&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;conio.h&amp;gt;
void insert(int n,int a[])
{
    int i,j,k; 
    for(i=1;i&amp;lt;=n;i++)
    {
        int temp=a[i];
        printf(&quot;\nPass %d: &quot;,i);
        for(k=0;k&amp;lt;n;k++)
        {
            printf(&quot;%d\t&quot;,a[k]);
        }
        for(j=i-1;j&amp;gt;=0;j--)
        {
            if(temp&amp;lt;a[j])
            { 
                a[j+1]=a[j];
                a[j]=temp;
            }
        }
    }
}
void main()
{
    int i,n,a[10];
    clrscr();
    printf(&quot;Enter no. of elements : &quot;);
    scanf(&quot;%d&quot;,&amp;amp;n);
    printf(&quot;Enter the elements in array : \n&quot;);
    for(i=0;i&amp;lt;n;i++)
    {
        scanf(&quot;%d&quot;,&amp;amp;a[i]);
    }
    insert(n,a);//call to function that performs the sorting
    printf(&quot;\nElements after sorting\n&quot;);
    for(i=0;i&amp;lt;n;i++)
    {
        printf(&quot;%d\t&quot;,a[i]);
    }
    getch();
}
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: text; gutter: false;&quot;&gt;Enter no. of elements : 4
Enter the elements in array :
75
35
47
15

Pass 1: 75      35      47      15
Pass 2: 35      75      47      15
Pass 3: 35      47      75      15
Pass 4: 15      35      47      75
Elements after sorting
15      35      47      75
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; The program above has been tested using TurboCPP. Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/5807776695441393293/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-to-implement-insertion-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/5807776695441393293'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/5807776695441393293'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-to-implement-insertion-sort.html' title='C program to implement Insertion sort'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-7713171697947188556</id><published>2013-06-10T08:59:00.001-07:00</published><updated>2013-07-14T10:55:23.694-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="Computer Graphics"/><title type='text'>Draw a smiley in C</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
C program to draw a smiley in C using graphics.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c; tab-size: 8; smart-tabs: false;highlight:[3,6,8];&quot;&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;conio.h&amp;gt;
#include &amp;lt;graphics.h&amp;gt;
void main()
{
    int gd=DETECT,gm;//DETECT is macro defined in graphics.h
    int color,pixel,maxx,maxy;
    initgraph(&amp;amp;gd,&amp;amp;gm,&quot;C:\\TC\\BGI&quot;);//initialize graphic mode
    setbkcolor(DARKGRAY);//set the background color
    maxx=getmaxx();//get maximum value for x co-ordinate
    maxy=getmaxy();//get maximum value for y co-ordinate
    setcolor(YELLOW);//color for drawing shapes
    circle(maxx/2,maxy/2,20);//draw a circle
    setfillstyle(1,YELLOW);//the style to fill the area
    fillellipse(maxx/2,maxy/2,100,100);//fill the ellipse with color(face)
    pixel=getpixel(1,1);
    setfillstyle(1,pixel);
    setcolor(pixel);
    fillellipse(maxx/2-50,maxy/2-30,10,10);//fill the ellipse with color(eye)
    fillellipse(maxx/2+50,maxy/2-30,10,10);//fill the ellipse with color(eye)
    ellipse(maxx/2,maxy/2,220,320,60,60);//draw an ellipse(mouth)
    line(maxx/2,maxy/2-10,maxx/2,maxy/2+20);//draw a line(nose)
    getch();
    closegraph();//close graphic mode
}&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuN0LfamHXUuS9-fAZGsoFR-RT2le_iW_Ly4zI9I_bv-_wosHy88eNTvdogrc3IbZQhvUgNbtMQCLCIfo7FTJSdd2U36nyemlDsSd4M_JiSK28UFRSfRw2D9b3EnsbDM83FhVmwcwdj9E/s1600/SMILYFACE.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;253&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuN0LfamHXUuS9-fAZGsoFR-RT2le_iW_Ly4zI9I_bv-_wosHy88eNTvdogrc3IbZQhvUgNbtMQCLCIfo7FTJSdd2U36nyemlDsSd4M_JiSK28UFRSfRw2D9b3EnsbDM83FhVmwcwdj9E/s1600/SMILYFACE.jpg&quot; style=&quot;background: none; border: none; box-shadow: none;&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; The image above is a graysace of the original image.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; The program above has been tested using TurboCPP. Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/7713171697947188556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/draw-smiley-in-c_10.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/7713171697947188556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/7713171697947188556'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/draw-smiley-in-c_10.html' title='Draw a smiley in C'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuN0LfamHXUuS9-fAZGsoFR-RT2le_iW_Ly4zI9I_bv-_wosHy88eNTvdogrc3IbZQhvUgNbtMQCLCIfo7FTJSdd2U36nyemlDsSd4M_JiSK28UFRSfRw2D9b3EnsbDM83FhVmwcwdj9E/s72-c/SMILYFACE.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-2106639774451019358</id><published>2013-06-09T00:20:00.003-07:00</published><updated>2013-07-14T10:52:31.813-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><title type='text'>C program to implement Bubble sort</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
C program to implement Bubble sort.&lt;br /&gt;
What is Bubble sort? &lt;a href=&quot;http://en.wikipedia.org/wiki/Bubble_sort&quot;&gt;Click here to read about it.&lt;/a&gt;&lt;br /&gt;
Bubble sort can be used to sort the items in ascending or descending order. It involves iterating through the list and swapping the adjacent elements until the list is sorted that is no swaps are needed.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Example :&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: text; gutter: false;&quot;&gt;45 36 28 10 5

Pass 0 :  45  36  28  10  5
Pass 1 :  36  28  10  5   45
Pass 2 :  28  10  5   36  45
Pass 3 :  10  5   28  36  45
Pass 4 :  5   10  28  36  45
&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Links that you may find important :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.sorting-algorithms.com/bubble-sort&quot;&gt;http://www.sorting-algorithms.com/bubble-sort&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.algolist.net/Algorithms/Sorting/Bubble_sort&quot;&gt;http://www.algolist.net/Algorithms/Sorting/Bubble_sort&lt;/a&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.algorithmist.com/index.php/Bubble_sort&quot;&gt;http://www.algorithmist.com/index.php/Bubble_sort&lt;/a&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.youtube.com/watch?v=tT4bJB0J4H4&quot;&gt;http://www.youtube.com/watch?v=tT4bJB0J4H4&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.youtube.com/watch?v=NiyEqLZmngY&quot;&gt;http://www.youtube.com/watch?v=NiyEqLZmngY&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c; tab-size: 8; smart-tabs: false;highlight:[13,15,35]&quot;&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;conio.h&amp;gt;
void bubble(int n,int a[])
{ 
    int temp,i,j,k;
    for(i=0;i&amp;lt;n;i++)
    {
        printf(&quot;\nPass %d: &quot;,i);
        for(k=0;k&amp;lt;n;k++)
        {  
            printf(&quot;%d\t&quot;,a[k]);
        }
        for(j=0;j&amp;lt;n;j++)
        {
            if(a[j]&amp;gt;a[j+1])
            {   
                temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }
    }
}
void main()
{
    int i,n,a[10];
    clrscr();
    printf(&quot;Enter no. of elements : &quot;);
    scanf(&quot;%d&quot;,&amp;amp;n);
    printf(&quot;Enter the elements in array : \n&quot;);
    for(i=0;i&amp;lt;n;i++)
    { 
        scanf(&quot;%d&quot;,&amp;amp;a[i]);
    } 
    bubble(n,a);//call to the function which sorts elements
    printf(&quot;\nElements after sorting\n&quot;);
    for(i=0;i&amp;lt;n;i++)
    {
        printf(&quot;%d\t&quot;,a[i]);
    }
    getch();
}&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: text; gutter: false;&quot;&gt;Enter no. of elements : 5
Enter the elements in array :
45
36
28
10
5

Pass 0: 45      36      28      10      5
Pass 1: 36      28      10      5       45
Pass 2: 28      10      5       36      45
Pass 3: 10      5       28      36      45
Pass 4: 5       10      28      36      45
Elements after sorting
5       10      28      36      45
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; The program above has been tested using TurboCPP. Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/2106639774451019358/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-to-implement-bubble-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/2106639774451019358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/2106639774451019358'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-to-implement-bubble-sort.html' title='C program to implement Bubble sort'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-6206718165891522358</id><published>2013-06-08T08:32:00.002-07:00</published><updated>2013-07-14T10:52:35.902-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><title type='text'>C program to find Simple and Compound interest</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
C program to find Simple and compound interest.&lt;br /&gt;
What is Simple interest? &lt;a href=&quot;http://www.investopedia.com/terms/s/simple_interest.asp&quot;&gt;Click here to read about it.&lt;/a&gt;&lt;br /&gt;
What is Compound interest? &lt;a href=&quot;http://www.investopedia.com/terms/c/compoundinterest.asp&quot;&gt;Click here to read about it.&lt;/a&gt;&lt;br /&gt;
Simple interest Formula : ( P x N x R )/100&lt;br /&gt;
Compound interest Formula : P ( 1 + R / 100)&lt;sup&gt;N&lt;/sup&gt;
&lt;br /&gt;
Where&lt;br /&gt;
P : The principal amount. &lt;br /&gt;
N : Number of years.&lt;br /&gt;
R : Rate of interest&lt;b style=&quot;color: #3cb2f6;&quot;&gt;.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Links that you may find important :&lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://math.about.com/od/businessmath/ss/Interest.htm&quot;&gt;http://math.about.com/od/businessmath/ss/Interest.htm&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://math.about.com/od/formulas/a/compound.htm&quot;&gt;http://math.about.com/od/formulas/a/compound.htm&lt;/a&gt;
&lt;b style=&quot;color: #3cb2f6;&quot;&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Code : &lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: c;highlight:[16,18]&quot;&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;conio.h&amp;gt;
#include &amp;lt;math.h&amp;gt;
void main()
{
        float p,si,ci,r;
        int n;
        clrscr();
        printf(&quot;Program to find Interest&quot;);
        printf(&quot;\n\nPrinciple amount :&quot;);
        scanf(&quot;%f&quot;,&amp;amp;p);
        printf(&quot;\nNumber of years :&quot;);
        scanf(&quot;%d&quot;,&amp;amp;n);
        printf(&quot;\nRate of interest:&quot;);
        scanf(&quot;%f&quot;,&amp;amp;r);
        si=p*n*r/100; //Simple interest calculation
        printf(&quot;\nSimple Interest = %1.2f&quot;,si);
        ci=p*pow(1+r/100,n); //Compound interest calculation
        printf(&quot;\nCompound Interest = %1.2f&quot;,ci);
        getch();
}&lt;/pre&gt;
&lt;b class=&quot;normal&quot;&gt;Output :&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: text; gutter: false;&quot;&gt;Program to find Interest

Principle amount :5000

Number of years :10

Rate of interest:7.5

Simple Interest = 3750.00
Compound Interest = 10305.16
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; Leave a comment if you feel the program is incorrect and/or has errors and/or if the program and its output don&#39;t match. Please report about broken links.
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/6206718165891522358/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-to-find-simple-and-compound.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/6206718165891522358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/6206718165891522358'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/c-program-to-find-simple-and-compound.html' title='C program to find Simple and Compound interest'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-7906227523937244578</id><published>2013-06-02T07:12:00.002-07:00</published><updated>2013-07-03T22:40:12.847-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><title type='text'>Having problems while running C or C++ program ?</title><content type='html'>Many a time beginners are faced with the problem while running a C or a C++ program. The common being not able to compile and run it. The error&#39;s like&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Unable to open include file &#39;IOSTREAM.H&#39;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;Unable to open include file &#39;CONIO.H&#39;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;Unable to open include file &#39;STDIO.H&#39;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
It seems to give an error for every file included using &lt;i&gt;#include&lt;/i&gt;. Its common to have such errors since people usually place the TurboC or TC or TurboCPP folder according to the location they prefer in the partition.  &lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Method 1 :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Placing it in the partition where Windows is loaded could solve this problem.
&lt;br /&gt;
&lt;pre class=&quot;brush: text; gutter: true;&quot;&gt;Locate the folder TC or TCPP or TC++ or TurboC
the above names may differ according to the source you have 
acquired it from
Copy the folder
Go to the partition where you have installed your Windows 
operating system
Open the partition
Paste it 
&lt;/pre&gt;
After installation the path should be like &lt;i&gt;[drive :]\TC&lt;/i&gt; . Where drive is the letter of your partition which in most of the cases is C. You can use the below method if still you aren&#39;t able to run the program.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Method 2 :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively if you dont want to place the folder in windows partition you can follow the steps below to solve the problem.
&lt;br /&gt;
&lt;pre class=&quot;brush: text; gutter: true; highlight:[7,8,11,14,16]&quot;&gt;Locate the TurboC or TCPP folder
again names vary according to sources you have acquired it from
Open the bin folder
Click TC.EXE
In the IDE or the window you are working in locate the menu bar 
at the top
Click on Options in the Menu bar
Click on Directories
Now besides Include Directories type the whole path to where you 
TC is located. For example
[drive : ]\path\tc\include
Now do the same for the text field located besides 
Library Directories. For example
[drive : ]\path\tc\lib
For Source and Output directories do the same. For example
[drive : ]\path\tc
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; By default the path specified are relative paths and hence dont work in partition&#39;s other than Windows. When you place your TCPP or TurboC folder in location other than Windows partition you have to explicitly mention the path to directories.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; If you feel something is incorrect or missing leave a comment  below.
</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/7906227523937244578/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/problems-while-running-c-or-c-program.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/7906227523937244578'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/7906227523937244578'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/problems-while-running-c-or-c-program.html' title='Having problems while running C or C++ program ?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-7777428489289647968</id><published>2013-06-01T23:58:00.001-07:00</published><updated>2013-06-22T12:28:50.932-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Setting path for running Java programs</title><content type='html'>The path is an environment variable in operating system like MS Windows,Linux. This variable can be set to values as per users convenience. The path environment variable is usually set so that it enables to compile and run Java program directly from any directory without having to set the path again and again.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Steps to set path :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Method 1 :&amp;nbsp;&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: text; gutter:true; highlight: [5]&quot;&gt;Click on start menu
Click on Run (Alternatively you can press Win+R keys)
Type cmd in the run window and press Enter key
In order to compile Java program you need to set path
set path=[drive:]\Program Files\Java\jdkx.x.x_x\bin;
where x.x.x_x is the version
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; The above method requires you to set the variable for every new instance of command prompt window opened.
&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Method 2 :&amp;nbsp;&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: text; gutter:true; highlight: [4,9,12]&quot;&gt;Right click on My Computer icon on Desktop
Click on Properties
Select the Advanced tab from the System Properties window
(Alternatively you can press Win+Pause/Break keys)
Click on the button named Environment Variables
In the Environment Variables window find variable named PATH under 
System variables and select it
Either double click the selection or click on Edit option below
In the field named Variable value put a semicolon (;) 
at the end of line (to go to end of line press the END key).
Copy paste the whole path to the bin directory in java
[drive:]\Program Files\Java\jdkx.x.x_x\bin
where x.x.x_x is the version
Click Ok in Edit Environment Variable window
Click Ok in Environment Variables window
Click Ok in System Properties window.
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; If you feel something is wrong or missing leave a comment  below. Please report about broken links.</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/7777428489289647968/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/setting-path-for-running-java-programs.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/7777428489289647968'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/7777428489289647968'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/06/setting-path-for-running-java-programs.html' title='Setting path for running Java programs'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4413331141661636442.post-8414193204759501255</id><published>2013-05-31T00:30:00.000-07:00</published><updated>2013-07-03T22:38:42.178-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Compiling and running Java program</title><content type='html'>To create a Java program type the code in a file and save it as ClassName.java (where ClassName is the name of the class in java file). If the ClassName doesn&#39;t match with the name of the class in ClassName.java file the program wont compile. The class you are compiling should have a main() method since this is where the program begins its execution. A program can have one main() method and any number of classes. You dont need to compile individual classes. &lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Steps to compile and run :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Method 1 :&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: text; gutter:true; highlight: [5,8,10,13]&quot;&gt;Click on start menu
Click on Run (Alternatively you can press Win+R keys)
Type cmd in the run window and press Enter key
In order to compile Java program you need to set path
set path=[drive:]\Program Files\Java\jdkx.x.x_x\bin;
where x.x.x_x is the version
In the command prompt type the path to locate the class file
cd /d [drive:]\path
Then to compile the program type 
javac ClassName.java
where ClassName.java is the file that contains the main() method.
Then to run the program type
java ClassName
&lt;/pre&gt;
&lt;span style=&quot;color: red;&quot;&gt;
&lt;b&gt;Note :&lt;/b&gt;&lt;/span&gt; Notice in the above we didnt mentioned the .java extension that is because the ClassName.java file doesn&#39;t run. Instead the ClassName.class file that is created after compilation is run.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;Method 2:&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: text; gutter:true;highlight:[6,9,12]&quot;&gt;Click on start menu
Click on Run (Alternatively you can press Win+R keys)
Type notepad in the run window and press Enter key
In order to compile Java program you need to set path. 
Type in notepad
set path=[drive:]\Program Files\Java\jdkx.x.x_x\bin;
where x.x.x_x is the version
Then to compile the program type in notepad
javac ClassName.java
where ClassName.java is the file that contains the main() method.
Then to run the program type in notepad
java ClassName
Save the file in the same directory where your .java file exists.
Name it as Filename.bat (where Filename is name of the file for 
example run.bat)
Double click on the .bat file to run.
&lt;/pre&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt; For programs that require an argument while running you
have to specify the parameter/s in the file while saving
(for example java ClassName 1 2 3)where 1 2 3 are three parameters that are 
separated using space.&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;normal&quot;&gt;For Netbeans click on the link below :&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;https://netbeans.org/kb/docs/java/quickstart.html&quot;&gt;https://netbeans.org/kb/docs/java/quickstart.html&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b class=&quot;important&quot;&gt;Note :&lt;/b&gt;If you feel something is incorrect or missing leave a comment  below. Please report about broken links.
</content><link rel='replies' type='application/atom+xml' href='http://knowledgepedia4u.blogspot.com/feeds/8414193204759501255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/05/compiling-and-running-java-program.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/8414193204759501255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4413331141661636442/posts/default/8414193204759501255'/><link rel='alternate' type='text/html' href='http://knowledgepedia4u.blogspot.com/2013/05/compiling-and-running-java-program.html' title='Compiling and running Java program'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/08342807479588100315</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>