<?xml version="1.0" encoding="UTF-8" standalone="no"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:gd="http://schemas.google.com/g/2005" xmlns:georss="http://www.georss.org/georss" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-770089786606021877</atom:id><lastBuildDate>Thu, 29 Aug 2024 21:41:46 +0000</lastBuildDate><category>C programs</category><category>Linux - How To's</category><category>Linux - FAQ's</category><category>C Theory</category><category>Games</category><title>C Bytes with spices of Linux &amp;amp; Opensource</title><description>Place for novice C programmers to  get solution for there programming enigmas</description><link>http://cnibbles.blogspot.com/</link><managingEditor>noreply@blogger.com (Binita M Shah)</managingEditor><generator>Blogger</generator><openSearch:totalResults>53</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><xhtml:meta content="noindex" name="robots" xmlns:xhtml="http://www.w3.org/1999/xhtml"/><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-5050356540078750089</guid><pubDate>Mon, 08 Jul 2013 15:57:00 +0000</pubDate><atom:updated>2013-07-10T12:10:38.320+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Encrypt a 4 digit number by adding 7 to each digit and swapping first with third &amp; 2nd with 4rth digit &amp; Decrypt to original again </title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Encrypt a 4 digit number in such a way that ,later on Decrypt the number to original number :&lt;br /&gt;
&lt;br /&gt;
1)Your program should read a four-digit integer in such a way that it replaces each digit by(sum of that digit + 7)&lt;br /&gt;
2)Swap 2nd digit with 4rth&lt;br /&gt;
3)Swap 1st digit with 3rd&lt;br /&gt;
4)Print the encrypted number&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;

#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int num,dig,mod,total = 0,div = 1000,base = 1000,dig1,dig2,dig3,dig4;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("Enter a 4 digit +ve number to be Encrypted : ");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf("%d",&amp;amp;num);&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; if ( num &amp;gt; 999 &amp;amp;&amp;amp; num &amp;lt;= 9999)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while ( num != 0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dig = num / div + 7;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; total = total * 10 + dig ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; num = num % base;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; div = div / 10;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; base = base / 10;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("Total encrypted number is %d",total);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dig1 = (total/1000);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dig2 = (total % 1000 / 100);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dig3 = (total % 100 / 10);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dig4 = (total % 10);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("\nNew Encrypted number is %d%d%d%d",dig3,dig4,dig1,dig2);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("Please Enter a 4 digit +ve number : ");&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; return 0;&lt;br /&gt;
}&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
&lt;code&gt;&lt;b&gt;Part 2 : Decryption to original number :&lt;/b&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;int main(void)&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; int num,dig1,dig2,dig3,dig4,base = 1000,div = 1000,mod,total = 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; printf("\nEnter an Encrypted four digit number : ");&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; scanf("%d",&amp;amp;num);&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; if ( num &amp;gt; 999 &amp;amp;&amp;amp; num &amp;lt;= 9999)&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dig1 = num / base ;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dig2 = (num % base)/100 ;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dig3 = (num % 100)/10 ;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dig4 = (num % 10);&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; num = dig3*1000+dig4*100+dig1*10+dig2;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while( num != 0)&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mod = num / base - 7;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; total = total + mod * base;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; base = base / 10;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; num = num % div;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; div = div / 10;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("\nDecrypted number is %d",total);&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; else&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("\nPlease enter a +ve 4 digit number &amp;amp; try again ");&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp; return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;span style="font-family: monospace;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://cnibbles.blogspot.com/2013/07/encrypt-4-digit-number-by-adding-7-to.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-4715776439510918901</guid><pubDate>Thu, 04 Jul 2013 12:30:00 +0000</pubDate><atom:updated>2013-07-04T18:00:59.117+05:30</atom:updated><title>Convert a Decimal number into Binary number </title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;code&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int number,mod,base = 1,total = 0 ;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("\nEnter a decimal number and I'll let you know Binary of it : ");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf("%d",&amp;amp;number);&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while ( number != 0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;mod = number % 2 ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;total = total + mod * base ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;number = number/2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;base = base * 10;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("\nBinary number of decimal %d is %d",number,total);&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return 0;&lt;br /&gt;
&lt;/code&gt;
&amp;nbsp; &lt;br /&gt;
}&lt;/div&gt;
</description><link>http://cnibbles.blogspot.com/2013/07/convert-decimal-number-into-binary.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-7915342224775336227</guid><pubDate>Wed, 03 Jul 2013 10:48:00 +0000</pubDate><atom:updated>2013-07-03T16:18:15.539+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Convert a Binary number to Decimal number without using Pow() or Arrays or Functions </title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; long int bin;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int total = 0 ,dec,mod,base =1 ;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("\nEnter a binary number(0's &amp;amp; 1's),I'll tell you its decimal : ");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf("%ld",&amp;amp;bin);&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while ( bin != 0 &amp;nbsp;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mod = bin % 10;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; total = total + base * mod;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; base = base * 2 ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bin = &amp;nbsp;bin / 10;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("\nDecimal of %ld is %d",bin,total);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return 0;&lt;br /&gt;
}&lt;/code&gt;&lt;/div&gt;
</description><link>http://cnibbles.blogspot.com/2013/07/convert-binary-number-to-decimal-number.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-5296794800760946915</guid><pubDate>Tue, 02 Jul 2013 17:37:00 +0000</pubDate><atom:updated>2013-07-02T23:07:47.160+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Enter a 5 digit number to see if its Palindrome number :-  For Eg : 12321,45554, 11611</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int i,mod,total,temp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("\nEnter a +ve 5 digit number : ");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf("%d",&amp;amp;i);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; temp = i;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if ( i &amp;gt; 9999 &amp;amp;&amp;amp; i &amp;lt;= 99999 )&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while ( i != 0) &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mod = i % 10;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; total = total * 10 + mod ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i = &amp;nbsp;i / 10;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; } &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if (total == temp)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("%i is Palindrome ",temp);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("%i is not Palindrome",temp);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("Pl. Enter a +ve 5 digit number :");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp;return 0;&lt;br /&gt;
}&lt;/div&gt;
</description><link>http://cnibbles.blogspot.com/2013/07/enter-5-digit-number-to-see-if-its.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-1609152506350741926</guid><pubDate>Sun, 30 Jun 2013 06:17:00 +0000</pubDate><atom:updated>2013-06-30T19:33:28.936+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Print an asterisks( * ) Square out of side size's number input </title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="color: purple;"&gt;Write a Program that reads in the side of a square and then prints that square out of asterisks.Your program should work for squares of all sides sizes between 1-20.For example it should look like this :&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: purple;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: purple;"&gt;*****&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: purple;"&gt;* &amp;nbsp; &amp;nbsp; &amp;nbsp;*&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: purple;"&gt;* &amp;nbsp; &amp;nbsp; &amp;nbsp;*&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: purple;"&gt;* &amp;nbsp; &amp;nbsp; &amp;nbsp;*&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: purple;"&gt;*****&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Code :&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int i = 1,sides,j = 1,m = 1,b = 1,n;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("Enter number of sides of square to be printed :");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf("%d",&amp;amp;sides);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while ( m &amp;lt;= sides)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("*");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; m++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; while ( b &amp;lt; sides - 1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("\n*");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; n = 2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while ( n &amp;lt; sides )&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(" ");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; n++ ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if ( n == sides)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf("*");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; b++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("\n") ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while ( i &amp;lt;= sides)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("*");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; } &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; return 0;&lt;br /&gt;
}&lt;/div&gt;
</description><link>http://cnibbles.blogspot.com/2013/06/write-program-that-reads-in-side-of.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-4834587590906492231</guid><pubDate>Thu, 02 Aug 2012 14:35:00 +0000</pubDate><atom:updated>2012-08-02T20:05:48.179+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><category domain="http://www.blogger.com/atom/ns#">Games</category><title>21 Matchstick Game in C</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
&lt;h3 class="post-title entry-title" itemprop="name" style="background-color: #eeeeee; font-family: Verdana, sans-serif; font-size: 16px; margin: 0px 0px 10px; padding: 2px 0px 2px 2px;"&gt;
&lt;span style="color: orange;"&gt;21 Matchstick Game using C Programming&lt;/span&gt;&lt;/h3&gt;
&lt;div class="post-header" style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 14px;"&gt;
&lt;div class="post-header-line-1"&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 14px; margin: 0px 6px 0px 5px;"&gt;
&lt;span style="color: orange;"&gt;&lt;span style="font-weight: bold;"&gt;Write a program for a matchstick game being played between the computer and a user.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Your program should ensure that the computer always wins. Rules for the game are as follows:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;-There are 21 matchsticks.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;-The computer asks the player to pick 1, 2, 3 or 4 matchsticks.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;-After the person picks, the computer does its picking.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;-Whoever is forced to pick up the last matchstick loses the game.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 14px; margin: 0px 6px 0px 5px;"&gt;
&lt;span style="color: orange;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 14px; margin: 0px 6px 0px 5px;"&gt;
&lt;b&gt;Code :&lt;/b&gt;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 14px; margin: 0px 6px 0px 5px;"&gt;
&lt;b&gt;=======&lt;/b&gt;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, Verdana, sans-serif; font-size: 14px; margin: 0px 6px 0px 5px;"&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="background-color: white; margin: 0px 6px 0px 5px;"&gt;
&lt;span style="font-family: Trebuchet MS, Trebuchet, Verdana, sans-serif;"&gt;&lt;span style="font-size: 14px;"&gt;&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
int main(void)&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
{&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; int i,total = 0,choice,matches = 21,left = 0,k = 0;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; while ( &amp;nbsp;total &amp;lt; 20 )&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("\nEnter your choice of match-sticks between 1-4 :");&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf("%d",&amp;amp;i);&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ( i &amp;gt; 4 || i &amp;lt;= 0 )&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf("Pl.Enter a valid no between 1,2,3 or 4 :");&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; total = total + i ;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; left = left - total ;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if( total &amp;gt;= 21)&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; choice = 5 - i ;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("\nComputer chooses %d",choice);&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; total = total+choice ;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; left = left - choice ;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("\n \nNow total match sticks are %d",total);&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; if (total == 20)&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp;{&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; while (k != 1)&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("\nEnter your choice of M-sticks you have just one left :");&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf("%d",&amp;amp;k);&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ( k != 1)&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("\nPl.enter valid choice : 1 ");&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; continue;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(k == 1)&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;total = total + k;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf("\nComputer wins as you are last to choose match-stick");&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf("\n \nNow total match sticks are %d",total);&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp;&amp;nbsp;&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="display: inline !important; margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp;} &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp;&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="display: inline !important; margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
}&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;return 0;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
}&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div class="post-body entry-content" id="post-body-115468524099172866" itemprop="articleBody" style="margin: 0px 6px 0px 5px;"&gt;
&amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;</description><link>http://cnibbles.blogspot.com/2012/08/21-matchstick-game-in-c.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-764894366618574205</guid><pubDate>Fri, 09 Sep 2011 06:15:00 +0000</pubDate><atom:updated>2011-09-09T11:45:36.867+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Find Binary Number Of Any Given Decimal Number</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;br /&gt;
/*Find Binary Number Of Any Given Decimal Number (In Reverse Order) */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int num,j,k = 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("Enter a number whose binary you want to know :");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf("%d",&amp;amp;num);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; j = num ;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while ( j &amp;gt; 0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; k = j % 2;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf("%d ",k );&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; j = j / 2 ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("\n");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return 0;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;/div&gt;
</description><link>http://cnibbles.blogspot.com/2011/09/find-binary-number-of-any-given-decimal.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-3820266713943053655</guid><pubDate>Fri, 09 Sep 2011 06:11:00 +0000</pubDate><atom:updated>2011-09-09T12:07:22.343+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Euclid's Geometric Position</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
/*According to Euclid's Geometric Position find Integer Factorization/Prime Factorization of Given Number */&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int i,num,j;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("Enter a number whose Prime factors you want to find :");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf("%d",&amp;amp;num);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; j = num ; &amp;nbsp; &amp;nbsp;//Assigning value of num to j&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; for ( i = 2 ; i &amp;lt;= j-1 ;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;while( num % i == 0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf("\n%d ",i );&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;num = num / i ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp;printf("\n");&lt;br /&gt;
&amp;nbsp; &amp;nbsp;return 0;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://cnibbles.blogspot.com/2011/09/euclids-geometric-position.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-411659188629381229</guid><pubDate>Mon, 05 Sep 2011 11:23:00 +0000</pubDate><atom:updated>2017-04-14T10:35:09.733+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>According to the Gregorian calendar,it was Monday on the date 01/01/1900.If any year is input through the keyboard write a program to find out what is the day on 1st January of this year</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="font-size: small;"&gt;&lt;br style="color: orange;" /&gt;&lt;br style="color: orange;" /&gt;&lt;span style="color: orange;"&gt;Solution code:-&lt;/span&gt;&lt;br /&gt;&lt;span style="color: orange;"&gt;=========&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: orange;"&gt;&lt;b&gt;Easy One (Irrespective of difference between year input from year 1901) :&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
/*According to the Gregorian calender, it was Monday on the date 01/01/01. If any year is input&lt;br /&gt;
&amp;nbsp;* through the keyboard write a program to find out what is the day on 1st January of this year?*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int yr,diff,lpyrdays,normaldays,res;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("\nEnter a year whose day of 1st Jan you want to know : ");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf("%d",&amp;amp;yr);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; yr = (yr - 1) ; //removing 1 year as only 1 day we are calculating of current yr&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lpyrdays = &amp;nbsp;(yr/4) &amp;nbsp;+ (yr / 400) - (yr / 100 ); //Calculating leap days in that particular year&lt;br /&gt;
&amp;nbsp; &amp;nbsp; normaldays = (yr* 365 )+ 1 + lpyrdays ; //Calculating normal days in that year &amp;amp; adding 1st jan's 1 day in&lt;br /&gt;
&amp;nbsp; &amp;nbsp; res = normaldays % 7;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(res==0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("\nSunday");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(res==1)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("Monday");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(res==2)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("Tuesday");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(res==3)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("Wednesday");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(res==4)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("Thursday");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(res==5)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("Friday");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(res==6)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf("Saturday");&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; return 0;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: orange;"&gt;&lt;b&gt;Tough One (Solution Code):&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int main(void)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //main function.. starting of c code&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int year,differ,lp_year,day_type;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; long int days;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("Please enter the year: ");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; scanf("%d",&amp;amp;year);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; year=year-1; //we will find days before given year so &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; differ=year-1900;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; /*as leap year is not divisible by 100.so,create 2 condition&lt;br /&gt;&amp;nbsp;&amp;nbsp; one difference less than 100 and greater than 100*/&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; if(differ&amp;lt;100)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp; lp_year=differ/4; //caln of total no. of leap year&lt;br /&gt;&amp;nbsp;&amp;nbsp; days=(366*lp_year)+((differ-lp_year)*365+365+1);//see Note1&lt;br /&gt;&amp;nbsp;&amp;nbsp; day_type=days%7; //caln of day type sun, mon......&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp; if(differ&amp;gt;=100)&lt;br /&gt;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp; lp_year=(differ/4)-(differ/100)+1+((year-2000)/400);//see Note2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp; days=(366*lp_year)+((differ-lp_year)*365+365+1);//see Note3&lt;br /&gt;&amp;nbsp;&amp;nbsp; day_type=days%7;&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;if(day_type==0)&lt;br /&gt;printf("\nSunday");&lt;br /&gt;if(day_type==1)&lt;br /&gt;printf("Monday");&lt;br /&gt;if(day_type==2)&lt;br /&gt;printf("Tuesday");&lt;br /&gt;if(day_type==3)&lt;br /&gt;printf("Wednesday");&lt;br /&gt;if(day_type==4)&lt;br /&gt;printf("Thursday");&lt;br /&gt;if(day_type==5)&lt;br /&gt;printf("Friday");&lt;br /&gt;if(day_type==6)&lt;br /&gt;printf("Saturday");&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&amp;nbsp; //int main() is function so value must be return.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //u will read in function chapter&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;br /&gt;/*Note1: &lt;br /&gt;-leap year has 366 day so lp_year*366&lt;br /&gt;-remaining year has 365 day so (differ-lp_year)*365&lt;br /&gt;-add 365 because we reduce 1 year&lt;br /&gt;-add 1 to make jan 1 on which we find day type&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;Note2:&lt;br /&gt;-(leap year come in every 4 year so) (differ/4) for leap year&lt;br /&gt;-(leap year isn't divisible by 100 so we subtract (differ/100)&lt;br /&gt;&amp;nbsp; from counting as leap year&lt;br /&gt;-(leap year will be if divisible by 400 so ((year-2000)/400)&lt;br /&gt;&amp;nbsp; to count that year as leap year&lt;br /&gt;- we calculate from 2000 so we add 1&lt;br /&gt;&lt;br /&gt;Note3:&lt;br /&gt;-leap year has 366 day so lp_year*366&lt;br /&gt;-remaining year has 365 day so (differ-lp_year)*365&lt;br /&gt;-add 365 because we reduce 1 year&lt;br /&gt;-add 1 to make jan 1 on which we find day type */&lt;/span&gt;&lt;/div&gt;
</description><link>http://cnibbles.blogspot.com/2011/09/according-to-gregorian-calendarit-was.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-8431814138121742882</guid><pubDate>Wed, 24 Aug 2011 12:58:00 +0000</pubDate><atom:updated>2011-08-24T18:37:04.377+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Validate if given number is Palindrome or not</title><description>&lt;div&gt;#include  &amp;lt;stdio.h&amp;gt;&lt;/div&gt;&lt;div&gt;int main(void)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;    int i,num,rev= 0,j = 0;&lt;/div&gt;&lt;div&gt;    printf("Enter a number for Palindrome check :");&lt;/div&gt;&lt;div&gt;    scanf("%d",&amp;amp;i);&lt;/div&gt;&lt;div&gt;    num = i;&lt;/div&gt;&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    while ( i != 0 )&lt;/div&gt;&lt;div&gt;    {&lt;/div&gt;&lt;div&gt;        rev = i % 10;&lt;/div&gt;&lt;div&gt;        j = rev + j * 10 ;&lt;/div&gt;&lt;div&gt;        i = i / 10 ;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div&gt;    if ( j == num)&lt;/div&gt;&lt;div&gt;        printf("\n %d is palindrome",num);&lt;/div&gt;&lt;div&gt;    else&lt;/div&gt;&lt;div&gt;        printf("\n %d is not Palindrome\n",num);&lt;/div&gt;&lt;div&gt;  &lt;/div&gt;&lt;div&gt;  return 0;&lt;/div&gt;&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://cnibbles.blogspot.com/2011/08/validate-if-given-number-is-palindrome.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-585936300807226516</guid><pubDate>Sun, 08 May 2011 13:20:00 +0000</pubDate><atom:updated>2011-05-08T18:57:55.044+05:30</atom:updated><title>Find Prime Factorization of given number</title><description>&lt;span style="color: rgb(255, 102, 0); font-weight: bold;"&gt;/*Find Prime Factorization Of Any Given Number */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt;    int i,num,j,k;&lt;br /&gt;    printf("Enter an integer whose Prime factors you want :");&lt;br /&gt;    scanf("%d",&amp;amp;num);&lt;br /&gt;    k = num ;&lt;br /&gt;    for(i = 2 ; i &amp;lt;= num ; i++)&lt;br /&gt;    {&lt;br /&gt;        for (j = 2 ; j &amp;lt;= i - 1 ; j++)&lt;br /&gt;        {&lt;br /&gt;            if ( i % j == 0)&lt;br /&gt;                break;&lt;br /&gt;        }&lt;br /&gt;        if (i == j)&lt;br /&gt;        {&lt;br /&gt;            while ( k % i == 0)&lt;br /&gt;            {&lt;br /&gt;                printf("%d ",i);&lt;br /&gt;                k = k / i ;&lt;br /&gt;                continue;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;         &lt;br /&gt;           &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;    return 0;&lt;br /&gt;}</description><link>http://cnibbles.blogspot.com/2011/05/find-prime-factorization-of-given.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-6493169494761403325</guid><pubDate>Sun, 21 Mar 2010 12:45:00 +0000</pubDate><atom:updated>2010-03-21T18:22:18.898+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Bifurcate entered sentence into uppercase,lowercase,number,special characters &amp; count at the end</title><description>&lt;div&gt;&lt;div&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="color:#FF6600;"&gt;&lt;b&gt;/*End user enters sentence/s and you need to bifurcate each entered character whether its number,uppercase character,lower case character ,special character,whitespace character,tab/new line and then reprint the same sentence/s on new line*/&lt;/b&gt;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;#include &amp;lt;stdio.h&amp;gt;&lt;stdio.h&gt;&lt;/stdio.h&gt;&lt;/div&gt;&lt;div&gt;int main(void)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;    int i;&lt;/div&gt;&lt;div&gt;    int big = 0,num = 0,sp = 0,small = 0,space = 0;&lt;/div&gt;&lt;div&gt;    while ( (i = getchar()) != EOF )&lt;/div&gt;&lt;div&gt;    {&lt;/div&gt;&lt;div&gt;        if (( i &gt;= 'a') &amp;amp;&amp;amp; ( i &lt;= 'z'))&lt;/div&gt;&lt;div&gt;            small++;&lt;/div&gt;&lt;div&gt;        else if (( i &gt;= 'A') &amp;amp;&amp;amp; ( i &lt;= 'Z'))&lt;/div&gt;&lt;div&gt;            big++;&lt;/div&gt;&lt;div&gt;        else if (( i &gt;= '0') &amp;amp;&amp;amp; (i &lt;= '9'))&lt;/div&gt;&lt;div&gt;            num++;&lt;/div&gt;&lt;div&gt;        else if ((( i &gt;= 0) &amp;amp;&amp;amp; (i &lt;= 31)) || (( i &gt;= 33) &amp;amp;&amp;amp; ( i &lt;= 47)) ||((i &gt;= 58) &amp;amp;&amp;amp; (i &lt;= 64)) || (( i &gt;= 91) &amp;amp;&amp;amp; ( i &lt;= 96)) || (( i &gt;= 123) &amp;amp;&amp;amp; ( i &lt;= 127))) //special characters&lt;/div&gt;&lt;div&gt;            sp++;&lt;/div&gt;&lt;div&gt;        else if (( i == 32) || ( i == 9) || ( i = 10) || ( i = 13)) // for space,tab,newline &lt;/div&gt;&lt;div&gt;            space++;&lt;/div&gt;&lt;div&gt;       &lt;/div&gt;&lt;div&gt;        putchar(i);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;    printf("%d lower characters are entered \n",small);&lt;/div&gt;&lt;div&gt;    printf("%d Uppercase characters are entered \n",big);&lt;/div&gt;&lt;div&gt;    printf("%d White space characters are entered \n",space);&lt;/div&gt;&lt;div&gt;    printf("%d Numerical characters are entered \n",num);&lt;/div&gt;&lt;div&gt;    printf("%d Special characters are entered \n",sp);&lt;/div&gt;&lt;div&gt;    return 0;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;</description><link>http://cnibbles.blogspot.com/2010/03/include-int-mainvoid-int-i-int-big-0num.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-8031247826847064212</guid><pubDate>Mon, 22 Feb 2010 12:10:00 +0000</pubDate><atom:updated>2010-02-22T17:48:44.782+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux - FAQ's</category><category domain="http://www.blogger.com/atom/ns#">Linux - How To's</category><title>Freenode IRC - Connect via Openssl with SASL authentication</title><description>&lt;pre&gt;&lt;br /&gt;Migration of freenode to new server from hyperion-ircd to ircd-seven happened in January end,2010.With which one can connect to IRC freenode via OpenSSL encryption between client &amp;amp; server .Using a script in Irssi one can get authentication via SASL.Freenode's standard port is 6667 but listen's for SSL connections on ports 7000 and 7070.So here are steps of how to get SSL and SASL setup for Irssi:&lt;br /&gt;&lt;br /&gt;1)&lt;b&gt;Perl libraries required:&lt;/b&gt; Before hand to run Irssi script pre-requisite perl lib are Blowfish, DH and BIGNUM&lt;br /&gt;&lt;br /&gt;2)&lt;b&gt;For Debian/Ubuntu ( install irssi,perl lib pre-requisites &amp;amp; Openssl) :&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;sudo apt-get install irssi openssl libcrypt-openssl-bignum-perl libcrypt-dh-perl libcrypt-blowfish-perl&lt;br /&gt;&lt;br /&gt;3)&lt;b&gt;At terminal:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;cd ~/.irssi/scripts&lt;br /&gt;sudo mkdir autorun  ## only if you do not have this directory already&lt;br /&gt;sudo wget http://www.freenode.net/sasl/cap_sasl.pl  ##location of cap_sasl.pl is ~/.irssi/scripts/autorun/&lt;br /&gt;cd autorun&lt;br /&gt;sudo ln -s ../cap_sasl.pl cap_sasl.pl&lt;br /&gt;&lt;br /&gt;4)&lt;b&gt;Start up irssi without connecting to anything :&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;irssi -!&lt;br /&gt;&lt;br /&gt;5)&lt;b&gt;Once in Irssi,at Status, setup your username and password for SASL:&lt;/b&gt;&lt;br /&gt;  /server add -auto -ssl -network freenode irc.freenode.net 7000&lt;br /&gt;  /server add -auto -ssl -ssl_cacert /etc/ssl/certs/GandiStandardSSLCA.pem -network freenode irc.freenode.net 7000(##Incase if you have any certification issues pass these command)  &lt;br /&gt;  /sasl set freenode your_nick your_password DH-BLOWFISH&lt;br /&gt;  /sasl save&lt;br /&gt;  /save&lt;br /&gt;    &lt;br /&gt;6)&lt;b&gt;Quit Irssi&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;7)&lt;b&gt;Edit config file of irssi :&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;sudo vi ~/.irssi/config (## search for section servers and see if below entries matches &amp;amp; update as below)&lt;br /&gt;&lt;br /&gt;  address = "chat.us.freenode.net";&lt;br /&gt;  chatnet = "freenode";&lt;br /&gt;  port = "7000";&lt;br /&gt;  use_ssl = "yes";&lt;br /&gt;  ssl_verify = "yes";&lt;br /&gt;  ssl_capath = "/etc/ssl/certs";&lt;br /&gt;  autoconnect = "yes";&lt;br /&gt;&lt;br /&gt;8)&lt;b&gt;Now simply fire up irssi-windows&lt;/b&gt; ( for window's navigation btw channels).You may get something like these :&lt;br /&gt;&lt;br /&gt;17:36 -!- Irssi: Looking up chat.us.freenode.net&lt;br /&gt;17:36 -!- Irssi: SASL: auth loaded from /home/binnishah/.irssi/sasl.auth&lt;br /&gt;17:36 -!- Irssi: Connecting to chat.us.freenode.net [140.211.166.4] port 7000&lt;br /&gt;17:36 -!- Irssi: Connection to chat.us.freenode.net established&lt;br /&gt;17:36 !niven.freenode.net *** Looking up your hostname...&lt;br /&gt;17:36 !niven.freenode.net *** Checking Ident&lt;br /&gt;17:36 -!- Irssi: CLICAP: supported by server: identify-msg multi-prefix sasl&lt;br /&gt;17:36 -!- Irssi: CLICAP: requesting: multi-prefix sasl&lt;br /&gt;17:36 -!- Irssi: CLICAP: now enabled: multi-prefix sasl&lt;br /&gt;17:36 -!- binnishah!binnishah@unaffiliated/abms1116 abms1116 You are now logged in as abms1116.&lt;br /&gt;17:36 -!- Irssi: SASL authentication successful&lt;br /&gt;17:36 -!- Welcome to the freenode Internet Relay Chat Network binnishah&lt;br /&gt;17:36 -!- Your host is niven.freenode.net[140.211.166.4/7000], running version ircd-seven-1.0.1&lt;br /&gt;17:36 -!- This server was created Sat Jan 30 2010 at 21:09:36 UTC&lt;br /&gt;17:36 -!- niven.freenode.net ircd-seven-1.0.1 DOQRSZaghilopswz CFILMPQbcefgijklmnopqrstvz bkloveqjfI&lt;br /&gt;17:36 -!- CHANTYPES=# EXCEPTS INVEX CHANMODES=eIbq,k,flj,CFLMPQScgimnprstz CHANLIMIT=#:120 PREFIX=(ov)@+ MAXLIST=bqeI:100 MODES=4 NETWORK=freenode KNOCK STATUSMSG=@+ CALLERID=g are supported by this server&lt;br /&gt;17:36 -!- SAFELIST ELIST=U CASEMAPPING=rfc1459 CHARSET=ascii NICKLEN=16 CHANNELLEN=50 TOPICLEN=390 ETRACE CPRIVMSG CNOTICE DEAF=D MONITOR=100 are supported by this server&lt;br /&gt;17:36 -!- FNC TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,PRIVMSG:4,NOTICE:4,ACCEPT:,MONITOR: EXTBAN=$,arx WHOX CLIENTVER=3.0 are supported by this server&lt;br /&gt;17:36 -!- There are 899 users and 52716 invisible on 23 servers&lt;br /&gt;17:36 -!- 37 IRC Operators online&lt;br /&gt;17:36 -!- 58 unknown connection(s)&lt;br /&gt;17:36 -!- 27761 channels formed&lt;br /&gt;17:36 -!- I have 2559 clients and 1 servers&lt;br /&gt;17:36 -!- 2559 4459 Current local users 2559, max 4459&lt;br /&gt;17:36 -!- 53615 60092 Current global users 53615, max 60092&lt;br /&gt;17:36 -!- Highest connection count: 4460 (4459 clients) (271988 connections received)&lt;br /&gt;17:36 -!- - niven.freenode.net Message of the Day&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;*Xchat configuration to SSL :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;From Menu select--&gt; Network list --&gt;Networks --&gt;Select freenode --&gt; Edit--&gt;Servers for freenode --&gt;Add "irc.freenode.net/7070" --&gt;set nickserv password&lt;br /&gt;On same window you may find --&gt; Connecting --&gt;Click on "Use SSL for all servers on these Network"&lt;br /&gt;&lt;br /&gt;On connection via SSL with port 7070 on Xchat ,you may find it like these:&lt;br /&gt;&lt;br /&gt;* * Certification info:&lt;br /&gt;*   Subject:&lt;br /&gt;*     OU=Domain Control Validated&lt;br /&gt;*     OU=Gandi Standard Wildcard SSL&lt;br /&gt;*     CN=*.freenode.net&lt;br /&gt;*   Issuer:&lt;br /&gt;*     C=FR&lt;br /&gt;*     O=GANDI SAS&lt;br /&gt;*     CN=Gandi Standard SSL CA&lt;br /&gt;*   Public key algorithm: rsaEncryption (2048 bits)&lt;br /&gt;*   Sign algorithm sha1WithRSAEncryption&lt;br /&gt;*   Valid since Jan 13 00:00:00 2010 GMT to Jan 13 23:59:59 2011 GMT&lt;br /&gt;* * Cipher info:&lt;br /&gt;*   Version: TLSv1/SSLv3, cipher DHE-RSA-AES256-SHA (256 bits)&lt;br /&gt;* Connected. Now logging in...&lt;br /&gt;* *** Looking up your hostname...&lt;br /&gt;* *** Checking Ident&lt;br /&gt;* Welcome to the freenode Internet Relay Chat Network abms1116&lt;br /&gt;* Your host is barjavel.freenode.net[78.40.125.4/7070], running version ircd-seven-1.0.0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Public Key   : 12695C6D&lt;br /&gt;Fingerprint : 0131 E273 B314 E8C8 2599  E32D 99AA 9362 1269 5C6D&lt;br /&gt;&lt;/pre&gt;</description><link>http://cnibbles.blogspot.com/2010/02/freenode-irc-connect-via-openssl-with.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-1761665694476398588</guid><pubDate>Mon, 26 Oct 2009 14:34:00 +0000</pubDate><atom:updated>2009-10-26T20:17:29.232+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux - How To's</category><title>How to enable TATA Photon whiz on Ubuntu 9.04/Fedora 11</title><description>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3WXxEz4dYOW2S4NbNA3UYdI40XSgvmqXwc7izqSyL8WuFmzo8VB_ANcxWgZhytv_xIvBYMx_pv7Cy0Ez92FciB3IriUBqZOqfXFSh4_bUgs95GSEdbvvJTJ_SmkI9lPKQJqHuDedbkA/s400/Tata-indicom-plug2surf-44.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 320px; height: 223px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3WXxEz4dYOW2S4NbNA3UYdI40XSgvmqXwc7izqSyL8WuFmzo8VB_ANcxWgZhytv_xIvBYMx_pv7Cy0Ez92FciB3IriUBqZOqfXFSh4_bUgs95GSEdbvvJTJ_SmkI9lPKQJqHuDedbkA/s400/Tata-indicom-plug2surf-44.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;For all those who are using TATA Photon whiz (Hauwei -EC121 or others) these is small - "How to for Ubuntu 9.04 Jaunty Jackalope &amp;amp; Fedora 11" ,which by default can't Plug n play (atleast for me on Ubuntu :))even with Network Manager Applet --&gt;Mobile broadband --&gt; Country = India --&gt; Provider --&gt;Tata indicom ( Plug2Surf) --&gt;Uname: internet,Password=internet,Ph =#777 ( As its CDMA).&lt;br /&gt;&lt;br /&gt;# Ubuntu 9.04 Photon Whiz set up&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1)&lt;/span&gt;&lt;span style="font-style: italic;"&gt;By default Ubuntu 9.04 doesn't have wvdial ,so you can install it via &lt;/span&gt;  &lt;span style="font-style: italic;"&gt;#Synaptic Package Manager --&gt;search for wvdial&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;---OR--&lt;br /&gt;Insert original Ubuntu Cd&lt;br /&gt;&lt;br /&gt;Go to System-&gt;Administration-&gt;software sources. add cd as a source and close . It will update itself, Then on terminal type,&lt;br /&gt;&lt;br /&gt;sudo apt-get install wvdial .&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2)&lt;/span&gt; &lt;span style="font-style: italic;"&gt;Type lsusb command and see what it gives (for me below was result)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;binnishah@google:~$ lsusb&lt;br /&gt;Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub&lt;br /&gt;Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;Bus 003 Device 002: ID 045e:00a4 Microsoft Corp.&lt;br /&gt;Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;Bus 002 Device 005: ID 12d1:1411 Huawei Technologies Co., Ltd. ---------&gt; ( Model #,vendor# &amp;amp; product# to trace for modprobe just in case your OS can't catch it plug n play)&lt;br /&gt;Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3)&lt;/span&gt;&lt;span style="font-style: italic;"&gt;I have Huawei Mobile connect whose model # is EC121 and vendor = 12d1 &amp;amp; product=1411&lt;/span&gt;&lt;br /&gt;next,&lt;br /&gt;&lt;br /&gt;modprobe usbserial vendor=0xAAAA product=0xBBBB ,&lt;br /&gt;&lt;br /&gt;Where AAAA is 12d1 and BBBB is 1411 in my case.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4)&lt;/span&gt;&lt;span style="font-style: italic;"&gt;Open terminal and give command ( pl.give these while inserting USB photon drive in lap/Server)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;sudo wvdialconf /etc/wvdial.conf  ---&gt;  (These will detect the modem and install it for internet connection by inserting appropriate modem configuration into /etc/wvdial.conf)&lt;br /&gt;&lt;br /&gt;** Pl.dont forget sudo or else you will be trapped into permission issues of /usr/sbin/pppd &amp;amp; chap-secrets &amp;amp; pap-secrets permissions and worse would be wvdial.conf wont get Baud speed rate self detected ,neither exact location of modem would be traced&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;5)&lt;/span&gt; &lt;span style="font-style: italic;"&gt;Open wvdial.conf in /etc with :-&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;sudo vi /etc/wvdial.conf ,it has some entries by default add some new &amp;amp; match it as belows:&lt;br /&gt;&lt;br /&gt;[Dialer Defaults]&lt;br /&gt;Init1 = ATZ&lt;br /&gt;Init2 = ATQ0 V1 E1 S0=0 &amp;amp;C1 &amp;amp;D2 +FCLASS=0&lt;br /&gt;Init3 = AT+CRM=1&lt;br /&gt;Stupid Mode = 1&lt;br /&gt;New PPPD = Yes&lt;br /&gt;Modem Type = USB Modem&lt;br /&gt;Phone = #777&lt;br /&gt;ISDN = 0&lt;br /&gt;Password = internet  ---&gt; Your ph number of tata/password&lt;br /&gt;Username = internet --&gt; Your uname /#&lt;br /&gt;Modem = /dev/ttyUSB0&lt;br /&gt;Baud = 9600  --&gt;Baud rate would be decided by 4rth command and written automatically into wvdial.conf script&lt;br /&gt;&lt;br /&gt;Now save &amp;amp; exit vi,&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;6)&lt;/span&gt;&lt;span style="font-style: italic;"&gt;type sudo wvdial &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It may give you something like these:--&lt;br /&gt;&lt;br /&gt;binnishah@google:~$ sudo wvdial&lt;br /&gt;--&gt; WvDial: Internet dialer version 1.60&lt;br /&gt;--&gt; Cannot get information for serial port.&lt;br /&gt;--&gt; Initializing modem.&lt;br /&gt;--&gt; Sending: ATZ&lt;br /&gt;ATZ&lt;br /&gt;OK&lt;br /&gt;--&gt; Sending: ATQ0 V1 E1 S0=0 &amp;amp;C1 &amp;amp;D2 +FCLASS=0&lt;br /&gt;ATQ0 V1 E1 S0=0 &amp;amp;C1 &amp;amp;D2 +FCLASS=0&lt;br /&gt;OK&lt;br /&gt;--&gt; Modem initialized.&lt;br /&gt;--&gt; Sending: ATDT#777&lt;br /&gt;--&gt; Waiting for carrier.&lt;br /&gt;ATDT#777&lt;br /&gt;CONNECT 153600&lt;br /&gt;--&gt; Carrier detected.  Starting PPP immediately.&lt;br /&gt;--&gt; Starting pppd at Sun Oct 18 17:47:48 2009&lt;br /&gt;--&gt; Pid of pppd: 13130&lt;br /&gt;--&gt; Using interface ppp0&lt;br /&gt;--&gt; local  IP address 121.245.189.171&lt;br /&gt;--&gt; remote IP address 172.23.119.14&lt;br /&gt;--&gt; primary   DNS address 202.54.29.5&lt;br /&gt;--&gt; secondary DNS address 202.54.10.2&lt;br /&gt;^CCaught signal 2:  Attempting to exit gracefully...&lt;br /&gt;--&gt; Terminating on signal 15&lt;br /&gt;--&gt; Connect time 5.1 minutes.&lt;br /&gt;--&gt; Disconnecting at Sun Oct 18 17:52:50 2009&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;7)&lt;/span&gt;&lt;span style="font-style: italic;"&gt;Command tail -f /var/log/messages --&gt; Just immediately aft.connection gives following:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;binnishah@google:~$ tail -f /var/log/messages&lt;br /&gt;Oct 18 17:47:48 google pppd[13130]: Warning - ***&lt;br /&gt;Oct 18 17:47:49 google pppd[13130]: CHAP authentication succeeded&lt;br /&gt;Oct 18 17:47:49 google pppd[13130]: CHAP authentication succeeded&lt;br /&gt;Oct 18 17:47:49 google pppd[13130]: local  IP address 121.245.189.171&lt;br /&gt;Oct 18 17:47:49 google pppd[13130]: remote IP address 172.23.119.14&lt;br /&gt;Oct 18 17:47:49 google pppd[13130]: primary   DNS address 202.54.29.5&lt;br /&gt;Oct 18 17:47:49 google pppd[13130]: secondary DNS address 202.54.10.2&lt;br /&gt;Oct 18 17:52:50 google pppd[13130]: Terminating on signal 15&lt;br /&gt;Oct 18 17:52:50 google pppd[13130]: Connect time 5.1 minutes.&lt;br /&gt;Oct 18 17:52:50 google pppd[13130]: Sent 158772 bytes, received 741237 bytes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;8)&lt;/span&gt;&lt;span style="font-style: italic;"&gt;If you dont want to fall in hassles of pwd ( I wouldn't recommend to do so ,though)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;sudo vi  /etc/sudoers&lt;br /&gt;&lt;br /&gt;# User privilege specification&lt;br /&gt;    username machine_name = NOPASSWD: /usr/bin/wvdial&lt;br /&gt;&lt;br /&gt;So next time when you give wvdial you dont need to type in password&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;*For Fedora-11 - TATA Photon Whiz :-&lt;/span&gt; &lt;span style="font-weight: bold;"&gt;==========================&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It came to me as surprise that Fed-11 took it in plug n play ie:- just some tweak with Network manager applet and I was sorted out with live n kicking&lt;br /&gt;tata photon whiz USB Mobile broadband&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1)&lt;/span&gt;Open Network manager applet&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2)&lt;/span&gt;In that,there's option of --&gt; Mobile Broadband --&gt;Add ( By default you will have Huawei Technologies or your preferable qualcom or whatever) --&gt;Select it --&gt;Forward --&gt;Country - India --&gt;Forward --&gt; Select Tata Indicom(Plug2Surf) if you have photon whiz --&gt;Forward -&gt;Commit changes by pressing apply&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3)&lt;/span&gt;In Popup of Editing tata Indicom&lt;br /&gt;Add your username &amp;amp; password&lt;br /&gt;and simply press apply&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4)&lt;/span&gt;Left click Network manager applet and you will have option of Tata Plug2surf ,select it and you are all set&lt;br /&gt;&lt;br /&gt;Hope that helps !!!&lt;br /&gt;&lt;br /&gt;*&lt;a style="font-weight: bold;" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3WXxEz4dYOW2S4NbNA3UYdI40XSgvmqXwc7izqSyL8WuFmzo8VB_ANcxWgZhytv_xIvBYMx_pv7Cy0Ez92FciB3IriUBqZOqfXFSh4_bUgs95GSEdbvvJTJ_SmkI9lPKQJqHuDedbkA/s400/Tata-indicom-plug2surf-44.jpg"&gt;Image courtesy&lt;/a&gt;</description><link>http://cnibbles.blogspot.com/2009/10/how-to-enable-tata-photon-whiz-on.html</link><author>noreply@blogger.com (Binita M Shah)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3WXxEz4dYOW2S4NbNA3UYdI40XSgvmqXwc7izqSyL8WuFmzo8VB_ANcxWgZhytv_xIvBYMx_pv7Cy0Ez92FciB3IriUBqZOqfXFSh4_bUgs95GSEdbvvJTJ_SmkI9lPKQJqHuDedbkA/s72-c/Tata-indicom-plug2surf-44.jpg" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-357587549504292312</guid><pubDate>Thu, 08 Oct 2009 09:13:00 +0000</pubDate><atom:updated>2009-10-08T14:47:09.732+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Determine Grade of steel</title><description>&lt;span style="color:#ff6600;"&gt;&lt;strong&gt;/*A certain grade of steel is graded according to the following conditions:&lt;br /&gt;*1)Hardness must be greater than 50&lt;br /&gt;*2)Carbon content must be less than 0.7&lt;br /&gt;*3)Tensile strength must be greater than 5600&lt;br /&gt;*&lt;br /&gt;*The grades are as follows:&lt;br /&gt;*&lt;br /&gt;*Grade is 10 if all three conditions are met&lt;br /&gt;*Grade is 9 if condition 1 &amp;amp; 2 are met&lt;br /&gt;*Grade is 8 if condition 2 &amp;amp; 3 are met&lt;br /&gt;*Grade is 7 if condition 1 &amp;amp; 3 are met&lt;br /&gt;*Grade is 6 if only one condition is met&lt;br /&gt;*Grade is 5 if none of the conditions are met&lt;br /&gt;*&lt;br /&gt;*Write a program which will require the user to give values of hardness,carbon content and tensile&lt;br /&gt;&lt;/strong&gt;&lt;/span&gt;&lt;p&gt;&lt;span style="color:#ff6600;"&gt;&lt;strong&gt; *strength of the steel under consideration and output the grade of the steel*/&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#999900;"&gt;# Solution code :&lt;/span&gt;&lt;/strong&gt;&lt;strong&gt;&lt;span style="color:#999900;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#999900;"&gt;==========&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt;   int hard,ts; // hard = hardness ; ts = tensile strength&lt;br /&gt;   float cc; //cc -- Carbon content&lt;br /&gt;&lt;br /&gt;   printf("\nEnter hardness of steel: ");&lt;br /&gt;   scanf("%d",&amp;amp;hard);&lt;br /&gt;   printf("\nEnter Carbon content of steel : ");&lt;br /&gt;   scanf("%f",&amp;amp;cc);&lt;br /&gt;   printf("\nEnter Tensile strenght of steel : ");&lt;br /&gt;   scanf("%d",&amp;amp;ts);&lt;br /&gt;&lt;br /&gt;   if ( (hard &amp;gt; 50) &amp;amp;&amp;amp; (cc &amp;lt; 0.7) &amp;amp;&amp;amp; (ts &amp;gt; 5600))&lt;br /&gt;       printf("Steel is of 10th Grade");&lt;br /&gt;   else if ( (hard &amp;gt; 50) &amp;amp;&amp;amp; (cc &amp;lt; 0.7))&lt;br /&gt;       printf("Steel is of 9th Grade");&lt;br /&gt;   else if ( (cc &amp;lt; 0.7) &amp;amp;&amp;amp; (ts &amp;gt; 5600 ))&lt;br /&gt;       printf("Steel is of 8th Grade");&lt;br /&gt;   else if (( hard &amp;gt; 50) &amp;amp;&amp;amp; (ts &amp;gt; 5600 ))&lt;br /&gt;       printf("Steel is of 7th Grade");&lt;br /&gt;   else if ( (hard &amp;gt; 50) || (cc &amp;lt; 0.7) || (ts &amp;gt; 5600))&lt;br /&gt;       printf("Steel is of 6th Grade");&lt;br /&gt;   else&lt;br /&gt;       printf("Steel is of 5th Grade");&lt;br /&gt;   return 0;&lt;br /&gt;}</description><link>http://cnibbles.blogspot.com/2009/10/determine-grade-of-steel.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-376110706790071604</guid><pubDate>Thu, 08 Oct 2009 03:34:00 +0000</pubDate><atom:updated>2009-10-08T09:18:02.135+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Determine if eligible for premium &amp; Policy</title><description>&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#FF6600;"&gt;/*An Insurance company follows rules to calculate premium&lt;/span&gt;&lt;/b&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#FF6600;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#FF6600;"&gt;1)If a person's health is excellent and the person is btw. 25 &amp;amp; 35 years of age and lives in city and is a male then the premium is Rs 4 per thousand and his policy amount cannot exceed Rs 2 lakhs.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#FF6600;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#FF6600;"&gt;2)If a person satisfies all the above conditions except that the sex is female then the premium is Rs 3 per thousand and her policy amount cannot exceed Rs 1 lakh.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#FF6600;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#FF6600;"&gt;3)If a person's health is poor and the person is btw. 25-35 and lives in village and is male ,the premium is Rs 6 per thousand and his policy cannot exceed Rs 10,000&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#FF6600;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#FF6600;"&gt;4)In all other cases the person is not insured&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#FF6600;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#FF6600;"&gt;Write a program to output whether the person should be insured or not ,his/her premium rate and maximum amount for which he/she can be insured.*/&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#999900;"&gt;#Solution&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#999900;"&gt;=======&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;int main(void)&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;{&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;    int age,pre,policy_amt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;    char sex,live,health;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;    printf("Enter your age : ");&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;    scanf("%d",&amp;amp;age);&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;    if ( age &amp;lt;= 35 &amp;amp;&amp;amp; age &amp;gt;= 25)&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;    {&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;        printf("\nPl.enter your health status ( h/p- h(healthy),p(poor health): ");&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;        scanf(" %c",&amp;amp;health);&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;        printf("\nDo you live in city/Village(c=city)(v=village): ");&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;        scanf(" %c",&amp;amp;live);&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;        printf("\nAre you Male/Female(m=male,f=female : ");&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;        scanf(" %c",&amp;amp;sex);&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;        if ( health == 'h')&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;        {&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;            &lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;            if ( sex == 'm'&amp;amp;&amp;amp; live == 'c')&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;                printf("\nYou are opt for Rs 4/- Preminum over 1000 Rs &amp;amp; Policy not greater than 2 lakh");&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;            else if ( sex == 'f'&amp;amp;&amp;amp; live == 'c')&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;                printf("\nYou are opt for Rs 3/- Preminum over 1000 Rs &amp;amp; Policy not greater than 1 lakh");&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;        }&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;        else if ( live == 'v' &amp;amp;&amp;amp; sex == 'm')&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;            printf("\nYou are opt for Rs 6/- Preminum over 1000 Rs &amp;amp; Policy not greater than 10,000 Rs/-");&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;        if ( sex == 'm' &amp;amp;&amp;amp; live == 'c' &amp;amp;&amp;amp; health == 'p')&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;             printf("\nSorry no premium or Policy for you");&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;        if ( sex == 'm' &amp;amp;&amp;amp; live == 'v' &amp;amp;&amp;amp; health == 'h')&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;             printf("\nSorry no premium or Policy for you");&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;        if ( sex == 'f' &amp;amp;&amp;amp; live == 'v' &amp;amp;&amp;amp; ((health == 'h') || (health == 'p' )))&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;            printf("\nSorry no premium or Policy for you");&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;        if ( sex == 'f' &amp;amp;&amp;amp; live == 'c' &amp;amp;&amp;amp; health == 'p')&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;            printf("\nSorry no premium or Policy for you");&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;    }&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;    else&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;        printf("\nYou are not eligible for Premium or Policy");&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;    return 0;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;}&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://cnibbles.blogspot.com/2009/10/determine-if-eligible-for-premium.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-4170733934538862645</guid><pubDate>Wed, 07 Oct 2009 18:40:00 +0000</pubDate><atom:updated>2009-10-08T00:22:12.622+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Determine character input if its Capital,small,decimal or special character</title><description>&lt;p&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;/*Any character is entered through the keyboard ,write a program to determine whether the character entered is a capital letter,a small case letter,a digit or a special symbol&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Following is Range of Ascii values for various characters:-&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Characters                                           Ascii Values&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;A-Z                                                        65-90&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;a-z                                                         97-122&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;0-9                                                         48-57&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;Special symbols                                   0-47,58-64,91-96,123-127 */&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span style="color:#ff6600;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;#1 Solution ( With Value of ASCII characters as integer as input) :-&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;========================================&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;int main(void)&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;{&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;int i;&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;printf("Enter a character to determine its type : ");&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;    scanf("%d",&amp;amp;i);&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;    if ( (i &amp;lt;= 90) &amp;amp;&amp;amp; (i &amp;gt;= 65))&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;        printf("\nIts %c whose value is %d ,which belongs to A-Z character type",i,i);&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;    else if ( i &amp;lt;= 122 &amp;amp;&amp;amp; i &amp;gt;= 97 )&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;        printf("\nIts %c whose value is %d,which belongs to a-z character type",i,i);&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;    else if ( i &amp;lt;= 57 &amp;amp;&amp;amp; i &amp;gt;= 48 )&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;        printf("\nIts %c whose value is %d,which belongs to 0-9 character type",i,i);&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;    else if (( i &amp;lt;= 47 &amp;amp;&amp;amp; i &amp;gt;= 0) || ( i &amp;lt;= 64 &amp;amp;&amp;amp; i &amp;gt;= 58) || ( i &amp;gt;= 91 &amp;amp;&amp;amp; i &amp;lt;= 96) || ( i &amp;lt;= 127 &amp;amp;&amp;amp; i &amp;gt;= 123))&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;        printf("\nIts %c whose value is %d,which belongs to specific symbols",i,i);&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;    return 0;&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;}&lt;/em&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;strong&gt;#2 Solution ( With ASCII Characters as input ) :-&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;==============================&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;int main(void)&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;{&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;    char i;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;printf("Enter a character to determine its type :");&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;    scanf("%c",&amp;amp;i);&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;    if (( i &amp;lt;= 'Z') &amp;amp;&amp;amp; (i &amp;gt;= 'A'))&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;         printf("\nIts %c whose value is %d ,which belongs to A-Z character type",i,i);&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;    else if (( i &amp;gt;= 'a') &amp;amp;&amp;amp; (i &amp;lt;= 'z' ))&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;        printf("\nIts %c whose value is %d,which belongs to a-z character type",i,i);&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;    else if ( (i &amp;gt;= '0') &amp;amp;&amp;amp; (i &amp;lt;= '9'))&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;        printf("\nIts %c whose value is %d,which belongs to 0-9 character type",i,i);&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;    else &lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;        printf("\nIts %c whose value is %d,which belongs to *special symbols*",i,i);&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;    return 0;&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;em&gt;}&lt;/em&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;/p&gt;</description><link>http://cnibbles.blogspot.com/2009/10/determine-character-input-if-its.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-7844296789698004283</guid><pubDate>Wed, 15 Apr 2009 05:11:00 +0000</pubDate><atom:updated>2009-04-15T10:43:09.462+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Calculate gross salary</title><description>&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;/*If his basic salary is less than Rs. 1500, then HRA = 10% of basic&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;salary and DA = 90% of basic salary. If his salary is either equal to&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;salary. If the employee's salary is input through the keyboard write&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;a program to find his gross salary.*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(153, 153, 0);"&gt;Solution Code:-&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(153, 153, 0);"&gt;=========&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt;    int bs;&lt;br /&gt;    float hra,da,gross;&lt;br /&gt;    printf("Enter Basic Salary : ");&lt;br /&gt;    scanf("%d",&amp;amp;bs);&lt;br /&gt;    if ( bs &amp;lt; 1500 )&lt;br /&gt;    {&lt;br /&gt;        hra = bs * 10 / 100;&lt;br /&gt;        da = bs * 90 /100;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    else&lt;br /&gt;{&lt;br /&gt;        hra = 500 ;&lt;br /&gt;        da = bs * 98 /100;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;     gross = hra + da + bs ;&lt;br /&gt;    printf("\n Your gross salary is %f",gross);&lt;br /&gt;    return 0;&lt;br /&gt;}</description><link>http://cnibbles.blogspot.com/2009/04/calculate-gross-salary.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-5306780451739113993</guid><pubDate>Tue, 14 Apr 2009 09:44:00 +0000</pubDate><atom:updated>2009-04-14T15:25:21.643+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Print a five digit number by adding one to each of its digits</title><description>&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;/*If a five-digit number is input through the keyboard, write a&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;program to print a new number by adding one to each of its&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;digits. For example if the number that is input is 12391 then&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;the output should be displayed as 23402.*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(153, 153, 0);"&gt;Solution Code :-&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(153, 153, 0);"&gt;=========&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;#include  &amp;lt;stdio.h&amp;gt;&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt;    int i,temp = 0;&lt;br /&gt;    printf("Enter a +ve 5 digit number :");&lt;br /&gt;    scanf("%d",&amp;amp;i);&lt;br /&gt;    if (( i &amp;lt;= 99999 ) &amp;amp;&amp;amp; ( i &amp;gt; 9999 ))&lt;br /&gt;{&lt;br /&gt;    printf(" %d",(i/10000) + 1);&lt;br /&gt;    printf(" %d",((( i/100) % 100)/10) + 1);&lt;br /&gt;    printf(" %d",(( i/100) % 10 ) + 1);&lt;br /&gt;    printf(" %d",((i % 100) / 10) + 1 );&lt;br /&gt;    printf(" %d",(i % 10) + 1);&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;    printf("\n Pl.enter +ve five digit number");&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;</description><link>http://cnibbles.blogspot.com/2009/04/print-five-digit-number-by-adding-one.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-3036354386974218879</guid><pubDate>Mon, 13 Apr 2009 01:12:00 +0000</pubDate><atom:updated>2009-04-13T06:45:27.849+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Calculate price of single item</title><description>&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;*If the total selling price of 15 items and the total profit earned&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;on them is input through the keyboard, write a program to&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;find the cost price of one item.*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;/*Here the query maker ,I suppose seeks for groce price rate of one item ,as groce profit &amp;amp; groce selling price is sought out&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;sin =&amp;gt; single item groce price ; procin =&amp;gt; profit on single item ;con =&amp;gt; conjugal price (profit + single item price)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 153, 0);"&gt;Solution Code :-&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 153, 0);"&gt;==========&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;int main(void)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    int price,profit,sin,prosin,con;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("Enter price of 15 items : ");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    scanf("%d",&amp;amp;price);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nEnter profit made on 15 items : ");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    scanf("%d",&amp;amp;profit);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    sin = price / 15 ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    prosin = (profit / 15) - sin;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    con = sin + prosin ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nSingle item cost is %d",sin);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nSingle item profit is %d",prosin);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nSingle item cost price is %d",con);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    return 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;</description><link>http://cnibbles.blogspot.com/2009/04/calculate-price-of-single-item.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-1123339993369063633</guid><pubDate>Sun, 12 Apr 2009 15:35:00 +0000</pubDate><atom:updated>2009-04-12T21:40:22.092+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Find total number of currency notes of each 10,50,100 denominations</title><description>&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;/*A cashier has currency notes of denominations 10, 50 and&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;100. If the amount to be withdrawn is input through the&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;keyboard in hundreds, find the total number of currency notes&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;of each denomination the cashier will have to give to the&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;withdrawer.*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 153, 0);"&gt;Solution Code:-&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 153, 0);"&gt;=========&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;int main(void)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    int amt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("Enter the amount to withdraw : ");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    scanf("%d",&amp;amp;amt);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nNotes of 100 required are %d", amt/100);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nWhile Notes of 50 required are %d", ((amt % 100)/50));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nAnd notes of 10 required are %d",((amt % 100)% 50)/10);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    return 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;</description><link>http://cnibbles.blogspot.com/2009/04/find-total-number-of-currency-notes-of.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-357738809942861977</guid><pubDate>Sun, 12 Apr 2009 15:28:00 +0000</pubDate><atom:updated>2009-04-12T21:03:39.885+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Percentage of Literate &amp; Illiterate along with men &amp; women in town</title><description>&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;/*In a town, the percentage of men is 52. The percentage of&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;total literacy is 48. If total percentage of literate men is 35 of&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;the total population, write a program to find the total number&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;of illiterate men and women if the population of the town is&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;80,000*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 153, 0); font-weight: bold; font-style: italic;"&gt;Solution Code:-&lt;/span&gt;&lt;br /&gt;===========&lt;br /&gt;&lt;span style="font-style: italic;"&gt;/*popmen = population of men,popwo = population of women&lt;/span&gt; &lt;span style="font-style: italic;"&gt;,literate women = ilwo,ilmen = ill-literate men,limen = literate men,liwo = literate women&lt;/span&gt;,li= literate men*/&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;#include  &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;int main(void)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    int popmen,popwo,ilmen,ilwo,li,limen,liwo,total; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    popmen = (80000 * 52)/100;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nTotal population of Men in town is %d out of 80000",popmen);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    popwo = (80000 - popmen);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nTotal population of women in town is %d out of 80000",popwo);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    li = ( 80000 * 48)/100;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nTotal literate population in town is %d",li);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    limen = ( popmen * 35 )/100;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nTotal amount of literate Men are %d",limen);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    ilmen = popmen - limen;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nTotal amount of Ill-literate Men are %d",ilmen);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    liwo = li - limen ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nTotal amount of Literate women is %d",liwo);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    ilwo = popwo - liwo ;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\n Total amount of Ill-literate women is %d",ilwo);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    return 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;</description><link>http://cnibbles.blogspot.com/2009/04/percentage-of-literate-illiterate-along.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-901844957918845153</guid><pubDate>Sat, 11 Apr 2009 13:47:00 +0000</pubDate><atom:updated>2009-04-12T07:50:36.853+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Calculate percentage of 5 subjects &amp; display Divison resp.</title><description>&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;/*The marks obtained by a student in 5 different subjects are input through keyboard.The student gets a division as per the following rules:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;Percentage above or equal to 60 - First division&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;Per btw 50 and 59 - Second div&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;per btw 40 and 49-Third div&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 102, 0);"&gt;per less than 40 - Fail */&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(153, 153, 0);"&gt;Solution Code:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(153, 153, 0);"&gt;=========&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;int main(void)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    int m1,m2,m3,m4,m5,sum,per;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("Enter marks for Math : ");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    scanf("%d",&amp;amp;m1);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nEnter marks for Chemistry : ");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    scanf("%d",&amp;amp;m2);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nEnter marks for Biology : ");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    scanf("%d",&amp;amp;m3);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nEnter marks for Physics : ");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    scanf("%d",&amp;amp;m4);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nEnter marks for English : ");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    scanf("%d",&amp;amp;m5);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    sum = (m1 + m2 + m3 + m4 + m5);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    per = (sum * 100 / 500);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nYou got %d percentage",per);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    if ( per &amp;gt;= 60 )&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nFirst Division");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    else if (( per &amp;lt;= 59) &amp;amp;&amp;amp; ( per &amp;gt;= 50 ))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nSecond Divison");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    else if (( per &amp;lt;= 49 ) &amp;amp;&amp;amp; ( per &amp;gt;= 40 ))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nThird Divison");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nSorry you Failed");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    return 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 153, 0);"&gt;2nd Solution Code:-&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(153, 153, 0);"&gt;===========&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt;    int m1,m2,m3,m4,m5,sum,per;&lt;br /&gt;    printf("Enter marks for Math : ");&lt;br /&gt;    scanf("%d",&amp;amp;m1);&lt;br /&gt;    printf("\nEnter marks for Chemistry : ");&lt;br /&gt;    scanf("%d",&amp;amp;m2);&lt;br /&gt;    printf("\nEnter marks for Biology : ");&lt;br /&gt;    scanf("%d",&amp;amp;m3);&lt;br /&gt;    printf("\nEnter marks for Physics : ");&lt;br /&gt;    scanf("%d",&amp;amp;m4);&lt;br /&gt;    printf("\nEnter marks for English : ");&lt;br /&gt;    scanf("%d",&amp;amp;m5);&lt;br /&gt;    sum = (m1 + m2 + m3 + m4 + m5);&lt;br /&gt;    per = (sum * 100 / 500);&lt;br /&gt;    printf("\nYou got %d percentage",per);&lt;br /&gt;&lt;br /&gt;    if ( per &amp;gt;= 60 )&lt;br /&gt;    printf("\nFirst Division");&lt;br /&gt;    else&lt;br /&gt;    {&lt;br /&gt;    if ( per &amp;gt;= 50 )&lt;br /&gt;    printf("\nSecond Division");&lt;br /&gt;&lt;br /&gt;    else&lt;br /&gt;    {&lt;br /&gt;    if ( per &amp;gt;= 40 )&lt;br /&gt;    printf("\nThird Division");&lt;br /&gt;&lt;br /&gt;    else&lt;br /&gt;    printf("\nFail");&lt;br /&gt;    }&lt;br /&gt;    }&lt;br /&gt;    return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;</description><link>http://cnibbles.blogspot.com/2009/04/calculate-percentage-of-5-subjects.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-5046899643013622460</guid><pubDate>Sat, 11 Apr 2009 13:31:00 +0000</pubDate><atom:updated>2009-04-11T19:13:47.914+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Example of compound statement &amp; nested if</title><description>&lt;span style="color: rgb(255, 102, 0); font-weight: bold; font-style: italic;"&gt;/*Prompts for and accepts input of an integer.Integer is tested to see that it meets the stated criteria.If it doesn't an error message is issued.If all criteria are met,execution terminates silently*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(153, 153, 0);"&gt;*Solution Code:-&lt;/span&gt;&lt;br /&gt;===========&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;int mod(int i);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;int main(void)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    int i;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("Enter an Even number less than 20 : ");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    scanf("%d",&amp;amp;i);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    if ( i  &amp;lt; 20)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        if ( mod(i))&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            printf("Oops you entered Odd number %d",i);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        else if ( i  &amp;lt;= 0 )&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;            printf("Oops you entered number less than or equal to 0 %d",i);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    else&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        printf("You entered a number greater than 20");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    return 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;int mod(int i)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    return ( i % 2 );&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;</description><link>http://cnibbles.blogspot.com/2009/04/example-of-compound-statement-nested-if.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-770089786606021877.post-5127204722629712513</guid><pubDate>Sat, 11 Apr 2009 05:38:00 +0000</pubDate><atom:updated>2009-04-11T12:50:28.411+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programs</category><title>Plays a one-time guessing game with user.User enters a number which is compared with target</title><description>&lt;span style="color: rgb(255, 102, 0); font-weight: bold; font-style: italic;"&gt;/*Plays a one-time guessing game with the user.The user enters a number,which is compared with TARGET.The computer issues a diagnostic message &amp;amp; then the correct result*/&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 153, 0); font-weight: bold; font-style: italic;"&gt;Solution Code:-&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 153, 0); font-weight: bold; font-style: italic;"&gt;=========&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;#include  &amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;#define TARGET 17&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;int test(int i,int target);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;int main(void)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    int i;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("Enter target number : ");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    scanf("%d",&amp;amp;i);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    test( i,TARGET);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    return 0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;void test(int i,int target)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    if ( i &amp;gt; target)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        printf("\nTarget number is smaller than %d,try again",i);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    else if ( i &amp;lt; target)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;        printf("\nTarget number is greater than %d,try again",i);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    else if ( i == target )&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    printf("\nFinally you could make it");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;    &lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;}&lt;/span&gt;</description><link>http://cnibbles.blogspot.com/2009/04/plays-one-time-guessing-game-with.html</link><author>noreply@blogger.com (Binita M Shah)</author><thr:total>0</thr:total></item></channel></rss>