<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-963554048139386376</id><updated>2011-07-07T19:45:57.154-07:00</updated><category term='C Programming'/><title type='text'>Sharing is caring</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://idiotsharing.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://idiotsharing.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Idiot</name><uri>http://www.blogger.com/profile/09250930802284134656</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>11</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-963554048139386376.post-4899895142291678309</id><published>2010-01-03T08:19:00.000-08:00</published><updated>2010-01-03T08:22:44.726-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C Programming'/><title type='text'>Structures</title><content type='html'>&lt;style type="text/css"&gt; .style1 {  margin-left: 80px; } &lt;/style&gt;&lt;p&gt;&lt;strong&gt;Structures&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Collection of related variables&lt;/li&gt;&lt;li&gt;derived data types&lt;/li&gt;&lt;li&gt;Contain variables of many different data types&lt;/li&gt;&lt;li&gt;Individual structure elements are known as members&lt;/li&gt;&lt;li&gt;The general syntax structure declaration is:&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;struct name_tag{&lt;br /&gt;    member_1;&lt;br /&gt;    member_2;&lt;br /&gt;    member_3;&lt;br /&gt;    ...&lt;br /&gt;    member_n;&lt;br /&gt;};&lt;/p&gt; &lt;ul&gt;&lt;li&gt;"struct" is a keyword&lt;/li&gt;&lt;li&gt;name_tag is a name that identifies the structure&lt;/li&gt;&lt;li&gt;The individual members can be ordinary variables, pointers, arrays and   other structures&lt;/li&gt;&lt;li&gt;Example&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;struct student{&lt;br /&gt;    int matrikno;&lt;br /&gt;    char name[40];&lt;br /&gt;    float height;&lt;br /&gt;};&lt;/p&gt; &lt;ul&gt;&lt;li&gt;A structure member can be accessed by a dot operator&lt;/li&gt;&lt;li&gt;The syntax of a dot operator is:&lt;ul&gt;&lt;li&gt;variable.member&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;li&gt;where variable refers to the name of a structure type variable and   member represents to the name of a member within a structure&lt;/li&gt;&lt;li&gt;Example&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;#include&lt;stdio.h&gt;&lt;br /&gt;&lt;br /&gt;struct studentdate{&lt;br /&gt;int matno;&lt;br /&gt;int month;&lt;br /&gt;int date;&lt;br /&gt;int year;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;int main (void){&lt;br /&gt;&lt;br /&gt;studentdate joiningdate;&lt;br /&gt;&lt;br /&gt;scanf("%d", &amp;amp;joiningdate.matno);&lt;br /&gt;scanf("%d", &amp;amp;joiningdate.month);&lt;br /&gt;scanf("%d", &amp;amp;joiningdate.date);&lt;br /&gt;scanf("%d", &amp;amp;joiningdate.year);&lt;br /&gt;&lt;br /&gt;printf("%d\n", joiningdate.matno);&lt;br /&gt;printf("%d\n", joiningdate.month);&lt;br /&gt;printf("%d\n", joiningdate.date);&lt;br /&gt;printf("%d\n", joiningdate.year);&lt;br /&gt;&lt;br /&gt;return 0;&lt;br /&gt;}&lt;/p&gt; &lt;p&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/963554048139386376-4899895142291678309?l=idiotsharing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://idiotsharing.blogspot.com/feeds/4899895142291678309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=963554048139386376&amp;postID=4899895142291678309' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/4899895142291678309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/4899895142291678309'/><link rel='alternate' type='text/html' href='http://idiotsharing.blogspot.com/2010/01/structures.html' title='Structures'/><author><name>Idiot</name><uri>http://www.blogger.com/profile/09250930802284134656</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-963554048139386376.post-7619703649889463537</id><published>2010-01-02T22:06:00.000-08:00</published><updated>2010-01-03T08:23:05.532-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C Programming'/><title type='text'>Pointers</title><content type='html'>&lt;style type="text/css"&gt; .style1 {  margin-left: 80px; } table.MsoTableGrid  {border:solid black 1.0pt;  font-size:11.0pt;  font-family:"Calibri","sans-serif";  } .style2 {  display: normal; } &lt;/style&gt; &lt;p&gt;&lt;strong&gt;Pointers&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;A variable that represents the location of a data item&lt;/li&gt;&lt;li&gt;Used to pass information between a function and its reference point&lt;/li&gt;&lt;li&gt;Provide a way to return multiple data items from a function&lt;/li&gt;&lt;li&gt;Every data item is stored in the computer memory and it occupies one or   more bytes of contiguous memory cells&lt;/li&gt;&lt;li&gt;Example&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;char letter;&lt;/p&gt; &lt;p class="style1"&gt;letter = 'A'&lt;/p&gt; &lt;table class="MsoTableGrid" style="border-collapse: collapse; margin-left: 80px;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 52.3pt;" valign="top" width="70"&gt;   &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none none solid; border-color: -moz-use-text-color -moz-use-text-color windowtext; border-width: medium medium 1pt; padding: 0in 5.4pt; width: 38.6pt;" valign="top" width="51"&gt;   &lt;p class="MsoNormal"&gt;letter&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid none none; border-color: -moz-use-text-color windowtext -moz-use-text-color -moz-use-text-color; border-width: medium 1pt medium medium; padding: 0in 5.4pt; width: 52.3pt;" valign="top" width="70"&gt;   &lt;p class="MsoNormal"&gt;5566&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 38.6pt;" valign="top" width="51"&gt;   &lt;p class="MsoNormal"&gt;65&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt; width: 52.3pt;" valign="top" width="70"&gt;   &lt;p class="MsoNormal"&gt;(Address Memory Location)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: medium none ; padding: 0in 5.4pt; width: 38.6pt;" valign="top" width="51"&gt;   &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;ul&gt;&lt;li&gt;The address of the variable can be determined using the expression,   &amp;amp;letter&lt;/li&gt;&lt;li&gt;The address can be stored to a new variable&lt;ul&gt;&lt;li&gt;pv = &amp;amp;letter&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;li&gt;The variable pv contains the address of the variable (1188) "letter"&lt;/li&gt;&lt;li&gt;The new variable is called pointer to "letter" since it points to the   location where the letter is stored in memory&lt;/li&gt;&lt;li&gt;The data item represented by "letter" can be accessed by the expression   *pv where * is an unary operator called indirection operator&lt;/li&gt;&lt;li&gt;The indirection operator * can operate only on address&lt;/li&gt;&lt;li&gt;Example 1&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;#include&lt;stdio.h&gt;&lt;br /&gt;&lt;br /&gt;int main (void){&lt;br /&gt;&lt;br /&gt;char letter;&lt;br /&gt;char *pletter;&lt;br /&gt;letter = 'A';&lt;br /&gt;&lt;br /&gt;printf("The address of the variable letter is %x\n", &amp;amp;letter);&lt;br /&gt;pletter = &amp;amp;letter&lt;br /&gt;printf("The address of the variable letter is %x\n", pletter);&lt;br /&gt;printf("The character stored in the letter is %c\n, letter);&lt;br /&gt;printf("The character stored in the letter is %c\n, *pletter);&lt;br /&gt;&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Result:&lt;br /&gt;The address of the variable letter is ABCD&lt;br /&gt;The address of the variable letter is ABCD&lt;br /&gt;The character stored in the letter is A&lt;br /&gt;The character stored in the letter is A&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Example 2&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;#include&lt;stdio.h&gt;&lt;br /&gt;&lt;br /&gt;int main (void){&lt;br /&gt;&lt;br /&gt;int a, b;&lt;br /&gt;int pta;&lt;br /&gt;a = 10;&lt;br /&gt;pta = &amp;a;&lt;br /&gt;b = 2 * (*pta + 15);&lt;br /&gt;printf("The expression value is %d\n", b);&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Result:&lt;br /&gt;The expression value is 50&lt;/p&gt; &lt;p&gt;&lt;strong&gt;%s format and %[ ] format specifier&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;The %s format and the square bracket specifiers are used to read string   of characters&lt;/li&gt;&lt;li&gt;%s format will read all the character from the input buffer till it   encounters a blank space&lt;/li&gt;&lt;li&gt;%[ ] format will read all the character from the input buffer till it   encounters a character that is not found in the list within the square   bracket&lt;/li&gt;&lt;li&gt;^ symbol is used as first symbol in  side the %[ ] format specifier   then it represents compliment of characters&lt;/li&gt;&lt;li&gt;Example 1:&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;#include&lt;stdio.h&gt;&lt;br /&gt;&lt;br /&gt;int main (void){&lt;br /&gt;&lt;br /&gt;char string[40];&lt;br /&gt;char string1[40];&lt;br /&gt;&lt;br /&gt;printf("Please enter the input string:");&lt;br /&gt;scanf("%s", string);&lt;br /&gt;printf("Please enter the input string1:");&lt;br /&gt;scanf("%[1234567890abcdefghijklmnopqrstuvwxyz]", string1);&lt;br /&gt;printf("The output for variable string is: %s\n", string);&lt;br /&gt;printf("The output for variable string1 is: %s", string1);&lt;br /&gt;&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Result:&lt;br /&gt;Please enter the input string: Today is very hot&lt;br /&gt;Please enter the input string1: Today is very hot&lt;br /&gt;The output for variable string is: Today&lt;br /&gt;The output for variable string1 is: Today is very hot&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Pointer and One Dimensional Array&lt;/strong&gt;&lt;/p&gt; &lt;table class="MsoTableGrid" style="margin-left: 40px;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;1800&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;1802&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;1804&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;1806&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;1808&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none none solid; border-color: -moz-use-text-color -moz-use-text-color windowtext; border-width: medium medium 1pt; padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;(2 bytes)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none none solid; border-color: -moz-use-text-color -moz-use-text-color windowtext; border-width: medium medium 1pt; padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;(2 bytes)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none none solid; border-color: -moz-use-text-color -moz-use-text-color windowtext; border-width: medium medium 1pt; padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;(2 bytes)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none none solid; border-color: -moz-use-text-color -moz-use-text-color windowtext; border-width: medium medium 1pt; padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;(2 bytes)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none none solid; border-color: -moz-use-text-color -moz-use-text-color windowtext; border-width: medium medium 1pt; padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;(2 bytes)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;50&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;60&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;70&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;80&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;90&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border: medium none ; padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;mark[0]&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: medium none ; padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;mark[1]&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: medium none ; padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;mark[2]&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: medium none ; padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;mark[3]&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: medium none ; padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;mark[4]&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;*mark&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;*(mark + 1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;*(mark + 2)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;*(mark + 3)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="padding: 0in 5.4pt;" valign="top"&gt;   &lt;p class="MsoNormal" align="center"&gt;*(mark + 4)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;ul&gt;&lt;li&gt;int mark [5] = {50, 60, 70, 80, 90}&lt;/li&gt;&lt;li&gt;The array of the first array element of mark can be represented as   &amp;amp;mark[0] or simply by the mark itself&lt;ul&gt;&lt;li&gt;&amp;amp;mark[0] and mark represent the same memory address which is the    1800&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;li&gt;The address of second array element can be written as &amp;amp;mark[1] or (mark   + 1)&lt;/li&gt;&lt;li&gt;In general, the address of (i +1)&lt;sup&gt;th &lt;/sup&gt;&lt;span class="style2"&gt;  array element cab be written as &amp;amp;mark[i] or (mark + i)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Example:&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;#include&lt;stdio.h&gt;&lt;br /&gt;&lt;br /&gt;int main (void){&lt;br /&gt;&lt;br /&gt;int i;&lt;br /&gt;int x[5] = {50, 60, 70, 80, 90};&lt;br /&gt;for(i=0;i&lt;5;i++)&lt;br /&gt;printf("i = %d, address is %x, value is %d\n", i, &amp;amp;x[i], x[i]);&lt;br /&gt;printf("\n");&lt;br /&gt;for(i=0;i&lt;5;i++)&lt;br /&gt;printf("i = %d, address is %x, value is %d\n", i, (x+i), *(x+i));&lt;br /&gt;return;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Output:&lt;br /&gt;0 address is 1800 value is 50&lt;br /&gt;1 address is 1800 value is 60&lt;br /&gt;2 address is 1800 value is 70&lt;br /&gt;3 address is 1800 value is 80&lt;br /&gt;4 address is 1800 value is 90&lt;br /&gt;&lt;br /&gt;0 address is 1800 value is 50&lt;br /&gt;1 address is 1800 value is 60&lt;br /&gt;2 address is 1800 value is 70&lt;br /&gt;3 address is 1800 value is 80&lt;br /&gt;4 address is 1800 value is 90&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/963554048139386376-7619703649889463537?l=idiotsharing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://idiotsharing.blogspot.com/feeds/7619703649889463537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=963554048139386376&amp;postID=7619703649889463537' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/7619703649889463537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/7619703649889463537'/><link rel='alternate' type='text/html' href='http://idiotsharing.blogspot.com/2010/01/pointers.html' title='Pointers'/><author><name>Idiot</name><uri>http://www.blogger.com/profile/09250930802284134656</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-963554048139386376.post-1955090559440927891</id><published>2009-12-17T19:11:00.000-08:00</published><updated>2010-01-03T08:23:05.532-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C Programming'/><title type='text'>Array</title><content type='html'>&lt;style type="text/css"&gt; table.MsoTableGrid  {border:solid black 1.0pt;  font-size:11.0pt;  font-family:"Calibri","sans-serif";  } .style1 {  margin-left: 80px; } .style2 {  text-align: left; } &lt;/style&gt; &lt;p&gt;&lt;strong&gt;Arrays&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Storing multiple data items of the same data type that can be represent   by a common name&lt;/li&gt;&lt;li&gt;The data items are allocated in continuous memory locations and can be   referred by a single name&lt;/li&gt;&lt;li&gt;Example:&lt;ul&gt;&lt;li&gt;int studentMark [5]&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;/ul&gt; &lt;table class="MsoTableGrid" style="border-collapse: collapse; margin-left: 120px;" align="left" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border-style: none solid none none; border-color: -moz-use-text-color windowtext -moz-use-text-color -moz-use-text-color; border-width: medium 1pt medium medium; padding: 0in 5.4pt; width: 41.4pt;" valign="top" width="55"&gt;   &lt;p class="MsoNormal" align="center"&gt;Index&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 45pt;" valign="top" width="60"&gt;   &lt;p class="MsoNormal" align="center"&gt;Value&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: medium none ; padding: 0in 5.4pt; width: 1.25in;" valign="top" width="120"&gt;   &lt;p class="MsoNormal" align="center"&gt;Memory Location&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid none none; border-color: -moz-use-text-color windowtext -moz-use-text-color -moz-use-text-color; border-width: medium 1pt medium medium; padding: 0in 5.4pt; width: 41.4pt;" valign="top" width="55"&gt;   &lt;p class="MsoNormal" align="center"&gt;0&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 45pt;" valign="top" width="60"&gt;   &lt;p class="MsoNormal" align="center"&gt;75&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: medium none ; padding: 0in 5.4pt; width: 1.25in;" valign="top" width="120"&gt;   &lt;p class="MsoNormal" align="center"&gt;100000&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid none none; border-color: -moz-use-text-color windowtext -moz-use-text-color -moz-use-text-color; border-width: medium 1pt medium medium; padding: 0in 5.4pt; width: 41.4pt;" valign="top" width="55"&gt;   &lt;p class="MsoNormal" align="center"&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 45pt;" valign="top" width="60"&gt;   &lt;p class="MsoNormal" align="center"&gt;80&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: medium none ; padding: 0in 5.4pt; width: 1.25in;" valign="top" width="120"&gt;   &lt;p class="MsoNormal" align="center"&gt;100002&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid none none; border-color: -moz-use-text-color windowtext -moz-use-text-color -moz-use-text-color; border-width: medium 1pt medium medium; padding: 0in 5.4pt; width: 41.4pt;" valign="top" width="55"&gt;   &lt;p class="MsoNormal" align="center"&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 45pt;" valign="top" width="60"&gt;   &lt;p class="MsoNormal" align="center"&gt;85&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: medium none ; padding: 0in 5.4pt; width: 1.25in;" valign="top" width="120"&gt;   &lt;p class="MsoNormal" align="center"&gt;100004&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid none none; border-color: -moz-use-text-color windowtext -moz-use-text-color -moz-use-text-color; border-width: medium 1pt medium medium; padding: 0in 5.4pt; width: 41.4pt;" valign="top" width="55"&gt;   &lt;p class="MsoNormal" align="center"&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 45pt;" valign="top" width="60"&gt;   &lt;p class="MsoNormal" align="center"&gt;90&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: medium none ; padding: 0in 5.4pt; width: 1.25in;" valign="top" width="120"&gt;   &lt;p class="MsoNormal" align="center"&gt;100006&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid none none; border-color: -moz-use-text-color windowtext -moz-use-text-color -moz-use-text-color; border-width: medium 1pt medium medium; padding: 0in 5.4pt; width: 41.4pt;" valign="top" width="55"&gt;   &lt;p class="MsoNormal" align="center"&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 45pt;" valign="top" width="60"&gt;   &lt;p class="MsoNormal" align="center"&gt;95&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border: medium none ; padding: 0in 5.4pt; width: 1.25in;" valign="top" width="120"&gt;   &lt;p class="MsoNormal" align="center"&gt;100008&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p class="MsoNormal" align="center"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="center"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="center"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="center"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="center"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="center"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="center"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="center"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="center"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="center"&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class="MsoNormal" align="center"&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;ul&gt;&lt;li&gt;Each individual data item is referred as an array element&lt;ul&gt;&lt;li&gt;studentMark[0] = 75&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;li&gt;Each array element is referred to by the array name followed by one or   more subscripts with each subscript enclosed in square brackets&lt;ul&gt;&lt;li&gt;studentMark[0]&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;li&gt;Each subscripts must be expressed as non-negative integer&lt;/li&gt;&lt;li&gt;An array must be declared and define before it can be used&lt;/li&gt;&lt;li&gt;Declaration and definition tell the compiler the name of the array, the   type of data and the number of elements&lt;/li&gt;&lt;li&gt;Example&lt;ul&gt;&lt;li&gt;An array name studentMark type integer and size 5&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;Data Type------Array Name-------Size&lt;br /&gt;int--------------studentMark-------[5]&lt;/p&gt; &lt;p class="style1"&gt;# include &lt;stdio.h&gt;&lt;br /&gt;int main( )&lt;br /&gt;{&lt;br /&gt;int n[10] = {32, 27, 64, 18, 95, 14, 90, 70, 60, 37};&lt;br /&gt;int i;&lt;br /&gt;&lt;br /&gt;printf("%s%13s\n", "Element", "Value");&lt;br /&gt;&lt;br /&gt;for(i = 0; i &lt;= 9; i++) printf("%7d%13d\n", i, n[i]); return 0; }&lt;/stdio.h&gt;&lt;/p&gt;  &lt;p&gt;Output:&lt;/p&gt; &lt;table class="MsoTableGrid" style="margin-left: 40px;" border="1" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border: 1pt solid black; padding: 0in 5.4pt; width: 0.7in;" valign="top" width="67"&gt;   &lt;p class="MsoNormal" align="center"&gt;Element&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: solid solid solid none; border-color: black black black -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 49.5pt;" valign="top" width="66"&gt;   &lt;p class="MsoNormal" align="center"&gt;Value&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 0.7in;" valign="top" width="67"&gt;   &lt;p class="MsoNormal" align="center"&gt;0&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 49.5pt;" valign="top" width="66"&gt;   &lt;p class="MsoNormal" align="center"&gt;32&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 0.7in;" valign="top" width="67"&gt;   &lt;p class="MsoNormal" align="center"&gt;1&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 49.5pt;" valign="top" width="66"&gt;   &lt;p class="MsoNormal" align="center"&gt;27&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 0.7in;" valign="top" width="67"&gt;   &lt;p class="MsoNormal" align="center"&gt;2&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 49.5pt;" valign="top" width="66"&gt;   &lt;p class="MsoNormal" align="center"&gt;64&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 0.7in;" valign="top" width="67"&gt;   &lt;p class="MsoNormal" align="center"&gt;3&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 49.5pt;" valign="top" width="66"&gt;   &lt;p class="MsoNormal" align="center"&gt;18&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 0.7in;" valign="top" width="67"&gt;   &lt;p class="MsoNormal" align="center"&gt;4&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 49.5pt;" valign="top" width="66"&gt;   &lt;p class="MsoNormal" align="center"&gt;95&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 0.7in;" valign="top" width="67"&gt;   &lt;p class="MsoNormal" align="center"&gt;5&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 49.5pt;" valign="top" width="66"&gt;   &lt;p class="MsoNormal" align="center"&gt;14&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 0.7in;" valign="top" width="67"&gt;   &lt;p class="MsoNormal" align="center"&gt;6&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 49.5pt;" valign="top" width="66"&gt;   &lt;p class="MsoNormal" align="center"&gt;90&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 0.7in;" valign="top" width="67"&gt;   &lt;p class="MsoNormal" align="center"&gt;7&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 49.5pt;" valign="top" width="66"&gt;   &lt;p class="MsoNormal" align="center"&gt;70&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 0.7in;" valign="top" width="67"&gt;   &lt;p class="MsoNormal" align="center"&gt;8&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 49.5pt;" valign="top" width="66"&gt;   &lt;p class="MsoNormal" align="center"&gt;60&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 0.7in;" valign="top" width="67"&gt;   &lt;p class="MsoNormal" align="center"&gt;9&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none solid solid none; border-color: -moz-use-text-color black black -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 49.5pt;" valign="top" width="66"&gt;   &lt;p class="MsoNormal" align="center"&gt;37&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt; &lt;p class="style2"&gt;&lt;strong class="style2"&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p class="style1"&gt;&lt;strong class="style1"&gt;Multi Dimensional Array&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;The number of subscripts determines the dimensionality of the array&lt;/li&gt;&lt;li&gt;The multi dimensional arrays are defined in much the same manner as   one-dimensional arrays&lt;/li&gt;&lt;li&gt;A pair of square brackets is required for each dimension&lt;/li&gt;&lt;li&gt;A two dimensional array will require two pairs of square brackets&lt;ul&gt;&lt;li&gt;int studentMark [5][10]&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/963554048139386376-1955090559440927891?l=idiotsharing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://idiotsharing.blogspot.com/feeds/1955090559440927891/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=963554048139386376&amp;postID=1955090559440927891' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/1955090559440927891'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/1955090559440927891'/><link rel='alternate' type='text/html' href='http://idiotsharing.blogspot.com/2009/12/table.html' title='Array'/><author><name>Idiot</name><uri>http://www.blogger.com/profile/09250930802284134656</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-963554048139386376.post-5922995950175838836</id><published>2009-12-17T19:06:00.000-08:00</published><updated>2010-01-03T08:23:05.533-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C Programming'/><title type='text'>Text Files</title><content type='html'>&lt;style type="text/css"&gt; .style1 {  margin-left: 80px; } &lt;/style&gt; &lt;p&gt;&lt;strong&gt;Files&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;A collection of related data treated as a unit&lt;/li&gt;&lt;li&gt;Files are store in secondary devices&lt;/li&gt;&lt;li&gt;Read files - the data move from the external device to RAM&lt;/li&gt;&lt;li&gt;Write files - the data move from RAM to external devices&lt;/li&gt;&lt;li&gt;The data movement uses a special work area called buffer that act as a   temporary storage area&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Files and Streams&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;A stream is a sequence of elements in time&lt;/li&gt;&lt;li&gt;A file is define by using a standard FILE type&lt;/li&gt;&lt;li&gt;The format for the file type is shown below&lt;ul&gt;&lt;li&gt;FILE *filename&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;li&gt;The asterisk is an address that pointed by the filename pointer&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Standard Library Input/Output Functions&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;The open/close functions, fopen and fclose, are used to open and close   the association between external files and internal streams&lt;/li&gt;&lt;li&gt;A file in C can be any of three basic modes:&lt;ul&gt;&lt;li&gt;reading, r&lt;/li&gt;&lt;li&gt;writing, w&lt;/li&gt;&lt;li&gt;appending, a&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;li&gt;Standard format&lt;ul&gt;&lt;li&gt;fopen ("filename", "mode");&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;li&gt;Example:&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;File *Infile;&lt;br /&gt;Infile = fopen ("Data.dat", "w");&lt;/p&gt; &lt;ul&gt;&lt;li&gt;When a file is opened in reading mode, the file marker is positioned at   the beginning of the existing file&lt;/li&gt;&lt;li&gt;When a file is opened in writing mode, the file marker is positioned at   the beginning of the newly created empty file&lt;/li&gt;&lt;li&gt;When a file is opened for appending, the file marker is positioned at   the end of existing file, before the end-of-file marker&lt;/li&gt;&lt;li&gt;fclose is used to closed and opened file&lt;ul&gt;&lt;li&gt;fclose(Infile);&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Formatting Input/Output Functions&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Formatted input/output functions allow read data from and write data to   file character by character while formatting to the desired data type&lt;/li&gt;&lt;li&gt;scanf and fscanf are used for reading&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;File *fpInput;&lt;br /&gt;fpInput = fopen("data.dat", "r");&lt;br /&gt;fscanf(fpInput,  "%d-%d-%d", &amp;amp;day, &amp;amp;month, &amp;amp;year);&lt;/p&gt; &lt;ul&gt;&lt;li&gt;printf and fprintf are used for writing&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;File *fpOutput;&lt;br /&gt;fpOutput = fopen("data.dat", "w");&lt;br /&gt;fprintf(fpOutput, "The date is %d-%d-%d", day, month, year);&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Example&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;#include &lt;stdio.h&gt;&lt;br /&gt;void main () {&lt;br /&gt;int num, sum = 0;&lt;br /&gt;FILE *inptr, *outptr;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;if ((inptr = fopen(“infile.txt”, “r”)) != NULL) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;while(fscanf(inptr, “%d”, &amp;amp;num) != EOF)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sum += num;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fclose(inptr);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ((outptr = fopen(“outfile.txt”, “w”)) != NULL) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fprintf(outptr,“The sum of the numbers is %d\n”,sum);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fclose(outptr); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;br /&gt;}&lt;br /&gt;return ;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Character Input and Output&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Character input and output are used to read or write files character by   character&lt;/li&gt;&lt;li&gt; fgetc, getc, and getchar can be used for reading&lt;/li&gt;&lt;li&gt;Example:&lt;ul&gt;&lt;li&gt;charatcter = getchar( )             //Get character from    keyboard&lt;/li&gt;&lt;li&gt;character = getc(filepointer)    //Get character from    file&lt;/li&gt;&lt;li&gt;character = fgetc(file pointer)  //Get character from file&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;li&gt;fputc, putc and putchar can be used for writing&lt;/li&gt;&lt;li&gt;Example&lt;ul&gt;&lt;li&gt;putchar(character)&lt;/li&gt;&lt;li&gt;fputc (character, filepointer)&lt;/li&gt;&lt;li&gt;putc (character, filepointer&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/963554048139386376-5922995950175838836?l=idiotsharing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://idiotsharing.blogspot.com/feeds/5922995950175838836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=963554048139386376&amp;postID=5922995950175838836' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/5922995950175838836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/5922995950175838836'/><link rel='alternate' type='text/html' href='http://idiotsharing.blogspot.com/2009/12/text-files.html' title='Text Files'/><author><name>Idiot</name><uri>http://www.blogger.com/profile/09250930802284134656</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-963554048139386376.post-4907499934356919026</id><published>2009-12-16T18:08:00.000-08:00</published><updated>2010-01-03T08:23:05.533-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C Programming'/><title type='text'>Functions</title><content type='html'>&lt;style type="text/css"&gt; .style1 {  margin-left: 80px; } .style2 {  margin-left: 40px; } &lt;/style&gt;&lt;p&gt;&lt;strong&gt;FUNCTIONS&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Functions in C is to decompose a program into its component functions means  smaller part to ease solving the problem&lt;/li&gt;&lt;li&gt;A C program is made up of one or more functions, exactly one of which must be  named main&lt;/li&gt;&lt;li&gt;The execution of the C program begins and terminates with main.&lt;/li&gt;&lt;li&gt;The main function can call other functions to do specific jobs&lt;/li&gt;&lt;li&gt;Functions is an independent module and each functions solves part of the problem&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Benefit of Functions&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Can test the components separately&lt;/li&gt;&lt;li&gt;Can change one function without changing or affecting the other functions&lt;/li&gt;&lt;li&gt;Provide a way to reuse code that is required in more than one place.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;Declared and Define Functions&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Like any other object in C, a function must be declared and defined&lt;/li&gt;&lt;li&gt;In order to use a function, there are three steps to be done:&lt;/li&gt;&lt;/ul&gt; &lt;ol class="style1"&gt;&lt;li&gt;Function declaration&lt;/li&gt;&lt;li&gt;Functions definition (function body)&lt;/li&gt;&lt;li&gt;Functions called&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;1. &lt;strong&gt;Function Declaration&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;A function declaration consist of three parts&lt;br /&gt;Return Type----Function Name----------(Parameter List);&lt;br /&gt;int--------------addnum------------------(int num1, int num2);&lt;/li&gt;&lt;li&gt;The return type of the function can be any of the basic data type (void, int,  float, char)&lt;/li&gt;&lt;li&gt; The name of the function is a valid C identifier.&lt;/li&gt;&lt;li&gt;The parameter list are the place holder for the arguments that the function  expects&lt;/li&gt;&lt;li&gt;The function declaration must end with a semicolon&lt;/li&gt;&lt;li&gt;The function declaration normally declare as global declaration in order to be  used in the whole program&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;2. &lt;strong&gt;Function Definition&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;A function definition is made up of two parts&lt;ul&gt;&lt;li&gt;Function header &lt;/li&gt;&lt;li&gt; Function body&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;li&gt;A function header is same as the function declaration just that there is no  semicolon at the end of the function header&lt;/li&gt;&lt;li&gt;A function body is a compound statement which enclosed between open and closed  braces&lt;/li&gt;&lt;li&gt;The function body contains local variable and declarations and statements and  terminated by a return statement&lt;/li&gt;&lt;li&gt;A return statement return a value to the main program and exit the function&lt;/li&gt;&lt;li&gt;Example:&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;int addnum (int num1, int num2)&lt;br /&gt;{&lt;br /&gt;int sum;&lt;br /&gt;sum = num1 + num2;&lt;br /&gt;return sum;&lt;br /&gt;}&lt;/p&gt; &lt;p&gt;3. &lt;strong&gt;Function call&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;A function call is used to call or invoke the function to be used in the C  program&lt;/li&gt;&lt;li&gt;A function call is an post fix expression&lt;/li&gt;&lt;li&gt;Example:&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;void main (void)&lt;br /&gt;{&lt;br /&gt;int a, b, result;&lt;br /&gt;scanf(“%d%d”, &amp;amp;a, &amp;amp;b)l;&lt;br /&gt;result = addnum (a, b);&lt;br /&gt;printf(“The sum is: %d”, result);&lt;br /&gt;return;&lt;br /&gt;}&lt;/p&gt; &lt;p&gt;The name of the function is used in three ways:&lt;/p&gt; &lt;p class="style2"&gt;1. For function declaration&lt;br /&gt;2. In a function call&lt;br /&gt;3. For function definition&lt;/p&gt; &lt;p&gt;There are two ways to call a function in C:&lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Call By Value&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;Every argument to a function is an expression, which has a value&lt;/li&gt;&lt;li&gt;C passes argument to an invoked function by making a copy of the expression  value, storing it in a temporary cell&lt;/li&gt;&lt;li&gt;Only the copy of the value is passed to the function argument&lt;/li&gt;&lt;li&gt;The original data in the calling function are unchanged. As only the copy of the  values are passed to the function.&lt;/li&gt;&lt;li&gt;Example:&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;#include &lt;stdio.h&gt;&lt;br /&gt;int change (int x);&lt;br /&gt;int main (void){&lt;br /&gt;     int a;&lt;br /&gt;     printf(“Enter a value: “);&lt;br /&gt;     scanf(“%d”, &amp;amp;a);&lt;br /&gt;     printf(“Value before call function: %d\n”, a);&lt;br /&gt;     change(a);&lt;br /&gt;     printf(“Value after call function: %d\n”, a);&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int change (int x){&lt;br /&gt;     x = 10;&lt;br /&gt;     return 0;&lt;br /&gt;}&lt;/p&gt; &lt;p class="style1"&gt;Output:&lt;br /&gt;Enter a value: 5&lt;br /&gt;Value before call function: 5&lt;br /&gt;Value after call function: 5&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Call by Reference&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;It links the variable identifiers in the calling function to their corresponding  parameters in the called function&lt;/li&gt;&lt;li&gt;When the called function changes a value in a variable, then it actually changes  the variables in the calling function&lt;/li&gt;&lt;li&gt;This is done by passing the an address to the called function&lt;br /&gt; &lt;ul&gt;&lt;li&gt;&amp;amp; - the address operator&lt;/li&gt;&lt;li&gt;* - the indirection operator&lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;li&gt;Example&lt;br /&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;#include &lt;stdio.h&gt;&lt;br /&gt;int change (int *x);&lt;br /&gt;int main (void){&lt;br /&gt;    int a;&lt;br /&gt;    printf(“Enter a value: “);&lt;br /&gt;    scanf(“%d”, &amp;amp;a);&lt;br /&gt;    printf(“Value before call function: %d\n”, a);&lt;br /&gt;    change(&amp;amp;a);&lt;br /&gt;    printf(“Value after call function: %d\n”, a);&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int change (int *x){&lt;br /&gt;     *x = 10;&lt;br /&gt;     return 0;&lt;br /&gt;}&lt;/p&gt; &lt;p class="style1"&gt;Output:&lt;br /&gt;Enter a value: 5&lt;br /&gt;Value before call function: 5&lt;br /&gt;Value after call function: 10&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Standard Library Functions&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt;&lt;li&gt;To perform various data manipulations functions will build in functions in the  header files&lt;/li&gt;&lt;li&gt;The functions called &lt;strong&gt;abs&lt;/strong&gt;, &lt;strong&gt;fabs&lt;/strong&gt;, and   &lt;strong&gt;labs&lt;/strong&gt; return the absolute value of a number&lt;/li&gt;&lt;li&gt;An absolute number value is the positive rendering of the value regardless of  its sign&lt;/li&gt;&lt;li&gt;Example:&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;int abs (int num)&lt;br /&gt;abs (-5) = 5&lt;br /&gt;double fabs (double num)&lt;br /&gt;fabs(-5.6) = 5.6&lt;/p&gt; &lt;ul&gt;&lt;li&gt;The &lt;strong&gt;ceil&lt;/strong&gt; function return the smallest integer value greater than or equal to the  number&lt;/li&gt;&lt;li&gt;Example:&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;ceil (1.2) = 2&lt;br /&gt;ceil (-2.85) =-2&lt;/p&gt; &lt;ul&gt;&lt;li&gt;The &lt;strong&gt;floor&lt;/strong&gt; function returns he largest integral value that is equal to or less  than a number&lt;/li&gt;&lt;li&gt;Example:&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;floor (1.2) = 1&lt;br /&gt;floor (-2.85) = -3&lt;/p&gt; &lt;ul&gt;&lt;li&gt;The &lt;strong&gt;pow&lt;/strong&gt; function returns the value of the x raised to the power y – that is xy&lt;/li&gt;&lt;li&gt;Example:&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;pow (3.0, 4.0) = 81.0&lt;br /&gt;pow (3.4, 2.3) =16.687893&lt;/p&gt; &lt;ul&gt;&lt;li&gt;The &lt;strong&gt;sqrt&lt;/strong&gt; function returns the non-negative square root of number&lt;/li&gt;&lt;li&gt;Example:&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;sqrt (36.0) = 6.0&lt;/p&gt; &lt;ul&gt;&lt;li&gt;The &lt;strong&gt;rand&lt;/strong&gt; function returns a pseudorandom integer between 0 and RAND_MAX, which  is defined in the standard library as the largest number that rand can generate&lt;/li&gt;&lt;li&gt;Example:&lt;/li&gt;&lt;/ul&gt; &lt;p class="style1"&gt;rand( )&lt;/p&gt; &lt;ul&gt;&lt;li&gt;  &lt;p class="style1"&gt;Generalizing the algorithm for generating a random number between ranges is&lt;/p&gt;  &lt;ul&gt;&lt;li&gt;   &lt;p class="style1"&gt;rand ( ) % ((max + 1) – min) + min&lt;br /&gt;  &lt;/p&gt;   &lt;/li&gt;&lt;/ul&gt;  &lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/963554048139386376-4907499934356919026?l=idiotsharing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://idiotsharing.blogspot.com/feeds/4907499934356919026/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=963554048139386376&amp;postID=4907499934356919026' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/4907499934356919026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/4907499934356919026'/><link rel='alternate' type='text/html' href='http://idiotsharing.blogspot.com/2009/12/functions.html' title='Functions'/><author><name>Idiot</name><uri>http://www.blogger.com/profile/09250930802284134656</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-963554048139386376.post-8437517990431264529</id><published>2009-08-26T23:56:00.000-07:00</published><updated>2010-01-03T08:23:05.533-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C Programming'/><title type='text'>Loops</title><content type='html'>&lt;span style="font-size:180%;"&gt;Loops&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Loop is to repeat the action over and over again&lt;/li&gt;&lt;li&gt;This condition to terminate or exit a loop is referred as loop control expression&lt;/li&gt;&lt;li&gt;C provide two looping statements namely: for, while and do...while&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;The while loop&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;pretest loop&lt;/li&gt;&lt;li&gt;It used an expression to control the loop&lt;/li&gt;&lt;li&gt;It test the expression before every iteration of the loop&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;      &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (expression){&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; Statements&lt;br /&gt;      &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;ul&gt;&lt;li&gt;As long as the expression is evaluated to true the statements in the loop body will be repeated.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;The for loop&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;a pretest loop&lt;/li&gt;&lt;li&gt;uses three expression&lt;/li&gt;&lt;li&gt;first expression contains initialization statements&lt;/li&gt;&lt;li&gt;the second contains the limit-test expression&lt;/li&gt;&lt;li&gt;the third contains the updating expression&lt;/li&gt;&lt;li&gt;A for loop is normally used when  the number of times of the loop to be executed are knowns&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(initialization; limit-test; updating){&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; Statements;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;ul&gt;&lt;li&gt;As long as the limit-test is evaluated to true the statements in the loop body will be repeated.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;The do...while loop&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;a post-test loop&lt;/li&gt;&lt;li&gt;It also uses an expression to control the loop&lt;/li&gt;&lt;li&gt;It tests the expression after the execution of the body&lt;/li&gt;&lt;li&gt;The do…while loop end with a semicolon&lt;/li&gt;&lt;li&gt;The do…while loop only test the expression at the end of the loop, the body of the loop will be at least execute for once&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do{&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; Statements;&lt;br /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }while (expression);&lt;br /&gt;&lt;ul&gt;&lt;li&gt;As long as the expression is evaluated to true the statements in the loop body will be repeated.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/963554048139386376-8437517990431264529?l=idiotsharing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://idiotsharing.blogspot.com/feeds/8437517990431264529/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=963554048139386376&amp;postID=8437517990431264529' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/8437517990431264529'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/8437517990431264529'/><link rel='alternate' type='text/html' href='http://idiotsharing.blogspot.com/2009/08/loops.html' title='Loops'/><author><name>Idiot</name><uri>http://www.blogger.com/profile/09250930802284134656</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-963554048139386376.post-5428702277791673708</id><published>2009-08-25T04:09:00.000-07:00</published><updated>2010-01-03T08:23:05.534-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C Programming'/><title type='text'>Selection Statement</title><content type='html'>&lt;span style="font-size:180%;"&gt;Selection Statement &lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;A selection statement is a control statement that allows choosing between two or more execution paths in a program.&lt;/li&gt;&lt;li&gt;C provide one-way, two-way and multiple conditional branching execution. &lt;/li&gt;&lt;li&gt;C provides this branching through two methods namely if statement and switch statement&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:130%;"&gt;If &lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;There are three ways of writing if statements. &lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;if &lt;/span&gt;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;if(expression){&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; Statements;&lt;br /&gt;        &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The expression is evaluated to either true or false.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;True is nonzero value and false is zero value.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The Statements inside the if will only be executed if the expression is evaluated to true &lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;if…else &lt;/span&gt;&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(expression){&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; Statements1;&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }else{&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; Statements2;&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;ul&gt;&lt;li&gt;If the expression is evaluated to true then Statements1 will be executed.&lt;/li&gt;&lt;li&gt;If the expression is evaluated to false then Statements2 will be executed.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;if…elseif &lt;/span&gt;&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(expression1){&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; Statements1;&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }elseif (expression2{&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; Statements2;&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }elseif (expression3){&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; Statements3;&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }else{&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; Statements4;&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;span style="font-size:180%;"&gt;&lt;br /&gt;Switch Statements &lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Switch is a composite statement used to make a decision between many alternatives&lt;/li&gt;&lt;li&gt;The expression of switch statements must be evaluated to either integer type or character constant. &lt;/li&gt;&lt;li&gt;The selection condition must be one of the C integral types&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;    &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; switch (expression){&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;  case constant-1: statement;&lt;br /&gt;                             &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;   …&lt;br /&gt;                             &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; statement;&lt;br /&gt;                            &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; break;&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; case constant-2: statement;&lt;br /&gt;                            &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; …&lt;br /&gt;                            &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; statement;&lt;br /&gt;                            &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; break;&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; case constant-n: statement;&lt;br /&gt;                            &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; …&lt;br /&gt;                            &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; statement;&lt;br /&gt;                            &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; break;&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; default            &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; : statement;&lt;br /&gt;                            &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; …&lt;br /&gt;                            &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; statement;&lt;br /&gt;                            &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; break;&lt;br /&gt;   &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Each case label must be a constant expression either integer or character&lt;/li&gt;&lt;li&gt;The case label simply provides an entry point to start executing the code &lt;/li&gt;&lt;li&gt;Default is executed whenever none of the other case values matches the value in the switch expression &lt;/li&gt;&lt;li&gt;The break statement causes the program to jump out of the switch statement; continue with the code after the switch statement&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/963554048139386376-5428702277791673708?l=idiotsharing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://idiotsharing.blogspot.com/feeds/5428702277791673708/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=963554048139386376&amp;postID=5428702277791673708' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/5428702277791673708'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/5428702277791673708'/><link rel='alternate' type='text/html' href='http://idiotsharing.blogspot.com/2009/08/selection-statement.html' title='Selection Statement'/><author><name>Idiot</name><uri>http://www.blogger.com/profile/09250930802284134656</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-963554048139386376.post-4542113652756323953</id><published>2009-08-22T03:21:00.000-07:00</published><updated>2010-01-03T08:23:05.534-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C Programming'/><title type='text'>Expressions</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:180%;"&gt;Expressions&lt;/span&gt;&lt;br /&gt;An expression is a sequence of operands and operators that reduces to a single value&lt;br /&gt;An operator is a language-specific syntactical token that requires an action to be taken.&lt;br /&gt;An operand receives an operator’s action.&lt;br /&gt;&lt;br /&gt;Precedence rule used to determine the order of execution between different operators in an expression.  The higher the number, the earlier the execution.&lt;br /&gt;Associativity rule used to determine the order of execution in which the operators with the same precedence level.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Assignment Expression&lt;/span&gt;&lt;br /&gt;Assignment Expression evaluates the operand on the right side of the operator (=) and places its value in the variable on the left.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Postfix Increment/Decrement&lt;/span&gt;&lt;br /&gt;The value of the postfix increments (decrements) expressions is determined before the variable is increase (decrease).&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;int a = 7;&lt;br /&gt;&lt;br /&gt;printf("%d\n", a)&lt;br /&gt;printf("%d\n", a++)&lt;br /&gt;printf("%d\n", a)&lt;br /&gt;&lt;br /&gt;Output:&lt;br /&gt;7&lt;br /&gt;7&lt;br /&gt;8&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;Prefix Increment/Decrement&lt;/span&gt;&lt;br /&gt;The value of the prefix increments (decrements) expressions is increase then the value is determined.&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;int a = 7;&lt;br /&gt;&lt;br /&gt;printf("%d\n", a);&lt;br /&gt;printf("%d\n", a++);&lt;br /&gt;printf("%d\n", a);&lt;br /&gt;&lt;br /&gt;Output:&lt;br /&gt;&lt;br /&gt;7&lt;br /&gt;8&lt;br /&gt;8&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/963554048139386376-4542113652756323953?l=idiotsharing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://idiotsharing.blogspot.com/feeds/4542113652756323953/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=963554048139386376&amp;postID=4542113652756323953' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/4542113652756323953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/4542113652756323953'/><link rel='alternate' type='text/html' href='http://idiotsharing.blogspot.com/2009/08/expressions.html' title='Expressions'/><author><name>Idiot</name><uri>http://www.blogger.com/profile/09250930802284134656</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-963554048139386376.post-8411621298449190698</id><published>2009-08-21T05:11:00.000-07:00</published><updated>2010-01-03T08:23:05.534-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C Programming'/><title type='text'>Printf and Scanf</title><content type='html'>&lt;span style="FONT-WEIGHT: bold;font-size:180%;" &gt;Printf&lt;/span&gt;&lt;br /&gt;Used for formatted output in C.&lt;br /&gt;Writes formatted data to the monitor&lt;br /&gt;Printf needs two things&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Instruction for formatting the data and&lt;/li&gt;&lt;li&gt;The actual data to be printed&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Example:&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int a;&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;char b;&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;float c;&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;double d;&lt;br /&gt;&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;printf("%d %c %f %lf", a, b, c, d);&lt;br /&gt;&lt;br /&gt;Conversion Code:&lt;br /&gt;&lt;br /&gt;int&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%d&lt;br /&gt;char&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%c&lt;br /&gt;float&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%f&lt;br /&gt;double&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%lf&lt;br /&gt;&lt;br /&gt;&lt;span style="FONT-WEIGHT: bold;font-size:180%;" &gt;Scanf&lt;/span&gt;&lt;br /&gt;Used for formatted input in C.&lt;br /&gt;Reads formatted data from the keyboard&lt;br /&gt;It consists of two parts&lt;br /&gt;&lt;ul&gt;&lt;li&gt;A format string that describes the data and &lt;/li&gt;&lt;li&gt;an address list that identifies where data are to be placed in memory&lt;/li&gt;&lt;/ul&gt;scanf requires that variables in the address list be represented by their address.&lt;br /&gt;To specify an address, you prefix the variable name with the address operator, the ampersand (&amp;amp;)&lt;span style="FONT-WEIGHT: bold"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Example&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int a;&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;char b;&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;float c;&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;double d;&lt;br /&gt;&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;scanf("%d %c %f %lf", &amp;amp;a, &amp;amp;b, &amp;amp;c, &amp;amp;d);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/963554048139386376-8411621298449190698?l=idiotsharing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://idiotsharing.blogspot.com/feeds/8411621298449190698/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=963554048139386376&amp;postID=8411621298449190698' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/8411621298449190698'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/8411621298449190698'/><link rel='alternate' type='text/html' href='http://idiotsharing.blogspot.com/2009/08/printf-and-scanf.html' title='Printf and Scanf'/><author><name>Idiot</name><uri>http://www.blogger.com/profile/09250930802284134656</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-963554048139386376.post-1699076821623026424</id><published>2009-08-14T06:23:00.000-07:00</published><updated>2010-01-03T08:23:05.534-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C Programming'/><title type='text'>Data Type, Variables and Constant</title><content type='html'>&lt;span style="font-size:180%;"&gt;Data Type&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;The are four basic data type for C namely:&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;char (character)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;int    (integer)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;float (floating-point number)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;void&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-size:180%;"&gt;Variables&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;Variables are named memory locations that have a type.&lt;br /&gt;&lt;br /&gt;Must declare and define in order to used it.&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;                   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int a;&lt;br /&gt;                   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;float b;&lt;br /&gt;                   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;char c;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Can not declare a variable of type void!!!&lt;/span&gt;&lt;br /&gt;Can initialize a value to it during the declarations refers as &lt;span style="font-weight: bold;"&gt;initialization.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Example&lt;br /&gt;&lt;br /&gt;                   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;int a = 1;&lt;br /&gt;                   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;float b = 1.0;&lt;br /&gt;                   &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;char c = 'a';&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:180%;"&gt;Constant&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;Data values that cannot b changed during the execution of the program.&lt;br /&gt;Character constants are enclosed between two single quotes.&lt;br /&gt;Example:&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'a'&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'\n'&lt;br /&gt;String constant is a sequence of zero or more characters enclosed in double quotes&lt;br /&gt;Examples:&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"a"&lt;br /&gt;          &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"ums"&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/963554048139386376-1699076821623026424?l=idiotsharing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://idiotsharing.blogspot.com/feeds/1699076821623026424/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=963554048139386376&amp;postID=1699076821623026424' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/1699076821623026424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/1699076821623026424'/><link rel='alternate' type='text/html' href='http://idiotsharing.blogspot.com/2009/08/data-type-variables-and-constant.html' title='Data Type, Variables and Constant'/><author><name>Idiot</name><uri>http://www.blogger.com/profile/09250930802284134656</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-963554048139386376.post-5990661919084826278</id><published>2009-08-14T06:05:00.000-07:00</published><updated>2010-01-03T08:23:05.535-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C Programming'/><title type='text'>C Program Structure</title><content type='html'>The C program structure serve as a important basic for understanding how to write a C program. This structure describe the important component for writing a C Program.&lt;br /&gt;&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;Preprocessor Directives&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;           &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Global Declarations&lt;br /&gt;&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;int main (void){&lt;br /&gt;&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;Local Definitions&lt;br /&gt;&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;Statements&lt;br /&gt;&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;return 0;&lt;br /&gt;                                                                         &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/963554048139386376-5990661919084826278?l=idiotsharing.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://idiotsharing.blogspot.com/feeds/5990661919084826278/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=963554048139386376&amp;postID=5990661919084826278' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/5990661919084826278'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/963554048139386376/posts/default/5990661919084826278'/><link rel='alternate' type='text/html' href='http://idiotsharing.blogspot.com/2009/08/c-program-structure.html' title='C Program Structure'/><author><name>Idiot</name><uri>http://www.blogger.com/profile/09250930802284134656</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry></feed>
