<?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:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" 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-7370931917763664578</atom:id><lastBuildDate>Thu, 05 Jun 2025 01:50:01 +0000</lastBuildDate><category>C programming</category><title>BesTutors - Tutor World</title><description></description><link>http://bestutors.blogspot.com/</link><managingEditor>noreply@blogger.com (Unknown)</managingEditor><generator>Blogger</generator><openSearch:totalResults>41</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><language>en-us</language><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-6710037151504566883</guid><pubDate>Sun, 05 Oct 2008 05:56:00 +0000</pubDate><atom:updated>2008-10-04T23:05:37.042-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>String - Array and String</title><description>&lt;table border="0" cellpadding="0" cellspacing="0" width="535"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="linespadding"&gt;&lt;span class="textbold"&gt;Strings&lt;/span&gt; in C are represented by&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;&lt;span style="font-weight: bold;" class="textbold"&gt;arrays&lt;/span&gt; of characters. The end of the&lt;span class="textbold"&gt; &lt;span style="font-weight: bold;"&gt;string&lt;/span&gt; &lt;/span&gt;is marked with a special character, the &lt;span style="font-weight: bold;" class="textbold"&gt;null character&lt;/span&gt;, which is simply the character with the value &lt;span class="textbold"&gt;0.&lt;/span&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Because C has no built-in facilities for manipulating entire &lt;span style="font-weight: bold;" class="textbold"&gt;arrays&lt;/span&gt; (copying them, comparing them, etc.), it also has very few built-in facilities for manipulating strings.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;In fact, C's only truly built-in string-handling is that it allows us to use &lt;span class="textbold"&gt;&lt;span style="font-weight: bold;"&gt;string constants&lt;/span&gt; &lt;/span&gt;(also called string literals) in our code.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Whenever we write a &lt;span class="textbold"&gt;&lt;span style="font-weight: bold;"&gt;string&lt;/span&gt;,&lt;/span&gt; enclosed in double quotes, C automatically creates an &lt;span class="textbold"&gt;&lt;span style="font-weight: bold;"&gt;array&lt;/span&gt; &lt;/span&gt;of characters for us, containing that string, terminated by the \0 character.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;For example, we can declare and define an &lt;span style="font-weight: bold;" class="textbold"&gt;array&lt;/span&gt; of characters, and initialize it with a string constant:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold;"&gt;     &lt;td class="textbold"&gt;char string[] = "Hello, world!";&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold;"&gt;     &lt;td class="textbold"&gt;Two ways to initilize string &gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoS41kk7fG0A7Q59djo7Reyuvw1hWpvy0kqQly2AwYLQ_20QH8UxNlNb73Tv2nCX5aR029SA2JjEm5FWs1vW59odlMxdhaD3vJ344xpKX8HUYPxiEa9sNN4SJHDUj7k9BE2Dd-JqSk4SSn/s1600-h/c12_06_01.gif"&gt;&lt;img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoS41kk7fG0A7Q59djo7Reyuvw1hWpvy0kqQly2AwYLQ_20QH8UxNlNb73Tv2nCX5aR029SA2JjEm5FWs1vW59odlMxdhaD3vJ344xpKX8HUYPxiEa9sNN4SJHDUj7k9BE2Dd-JqSk4SSn/s400/c12_06_01.gif" alt="" id="BLOGGER_PHOTO_ID_5253546436697631666" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;table border="0" cellpadding="0" cellspacing="0" width="535"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;In this case, we can leave out the dimension of the &lt;span class="textbold"&gt;array&lt;/span&gt;, since the compiler can compute it for us based on the size of the initializer. &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;This is the only case where the compiler sizes a string &lt;span class="textbold"&gt;array &lt;/span&gt;for us, however; in other cases, it will be necessary that we decide how big the &lt;span class="textbold"&gt;arrays &lt;/span&gt;we use to hold strings. &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold;"&gt;     &lt;td class="textbold"&gt;An example program showing the character data type array:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil-W4O-HFnb96VHZWFSzJnWYB3f4fL0KRfnP-WgozpGlNPyvK_tW7hBiYxnOCVVbd1tvtrcSIrjvRK4q4e1JsUP460ex_-zRFuFEtqCNgeW02hiBRcpTyr7Dy2ALXV0pOjFKZY-LuLkAQ7/s1600-h/c12_06_02.gif"&gt;&lt;img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil-W4O-HFnb96VHZWFSzJnWYB3f4fL0KRfnP-WgozpGlNPyvK_tW7hBiYxnOCVVbd1tvtrcSIrjvRK4q4e1JsUP460ex_-zRFuFEtqCNgeW02hiBRcpTyr7Dy2ALXV0pOjFKZY-LuLkAQ7/s400/c12_06_02.gif" alt="" id="BLOGGER_PHOTO_ID_5253546443388071058" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="display: block;" id="formatbar_Buttons"&gt;&lt;span class="on down" style="display: block;" id="formatbar_JustifyCenter" title="Align Center" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 11);ButtonMouseDown(this);"&gt;&lt;img src="img/gl.align.center.gif" alt="Align Center" border="0" /&gt;&lt;/span&gt;&lt;/span&gt;Out put of the program&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1faHKHMqwo8aMboekC77Zn_ZfIq8cLNr-rkNm6eztTeMZ66Mdkzcr_F13GYIOGjj4euBtX3AjQ6_PoxBKigqN9iFhjJll1aJBbj7oVJwDKX5khYX0i-PHoxvSImPH7qxOOQvftEJgrfat/s1600-h/c12_06_03.gif"&gt;&lt;img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1faHKHMqwo8aMboekC77Zn_ZfIq8cLNr-rkNm6eztTeMZ66Mdkzcr_F13GYIOGjj4euBtX3AjQ6_PoxBKigqN9iFhjJll1aJBbj7oVJwDKX5khYX0i-PHoxvSImPH7qxOOQvftEJgrfat/s400/c12_06_03.gif" alt="" id="BLOGGER_PHOTO_ID_5253546439859844226" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;table border="0" cellpadding="0" cellspacing="0" width="535"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="linespadding"&gt;In the above example, a character based &lt;span class="textbold"&gt;array&lt;/span&gt; named word is declared, and each element of &lt;span class="textbold"&gt;array&lt;/span&gt; is assigned a character.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;The last element is filled with a zero value, to signify the end of the &lt;span class="textbold"&gt;character string &lt;/span&gt;(in C, there is no string type, so character based arrays are used to hold strings).&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;A&lt;span class="textbold"&gt; printf &lt;/span&gt;statement is then used to &lt;span class="textbold"&gt;print out&lt;/span&gt; all elements of the &lt;span class="textbold"&gt;array&lt;/span&gt;.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description><link>http://bestutors.blogspot.com/2008/10/string-array-and-string.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoS41kk7fG0A7Q59djo7Reyuvw1hWpvy0kqQly2AwYLQ_20QH8UxNlNb73Tv2nCX5aR029SA2JjEm5FWs1vW59odlMxdhaD3vJ344xpKX8HUYPxiEa9sNN4SJHDUj7k9BE2Dd-JqSk4SSn/s72-c/c12_06_01.gif" width="72"/><thr:total>1</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-450451204213395846</guid><pubDate>Sun, 05 Oct 2008 05:50:00 +0000</pubDate><atom:updated>2008-10-04T22:53:34.795-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Function Definition - Function and Recursion</title><description>&lt;table style="text-align: left; margin-left: 0px; margin-right: 0px;" border="0" cellpadding="0" cellspacing="0" width="535"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="linespadding"&gt;&lt;span class="textbold"&gt;Functions&lt;/span&gt; are self contained program segments that carry out some specific well defined task.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt; In "C" , we include the header files like&lt;span class="textbold"&gt; &lt;span style="font-weight: bold;"&gt;stdio, conio, string,&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; etc&lt;/span&gt;.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;These files contain number of library functions which are as follows:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold;"&gt;     &lt;td style="text-align: justify;" class="textbold"&gt;printf( ), scanf( ), getchar( ), putchar( ), getche( ), gets( ), puts( ), strlen( ), getch( ), etc.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;In C it is possible for the function to call themselves.  we will see how it can be possible through Recursions.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;A Function is a self-contained block of statement that perform a coherent task of some kind. Every C program must have a function. One of the function must be &lt;span class="textbold"&gt;main()&lt;/span&gt;.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;Why should we use Function?&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;a) Using function it becomes easier to write programs and keep track of what they are doing&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;b) Length of the program can be reduced by using function.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;c) Debugging is easier.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;d) It facilitates top-down modular programming.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;Classification of Function&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;C function can be classified into two categories:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;1. Library function:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;They are predefined in the standard library of C. We need  to include the Library.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;2. User-defined function:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt; User defined functions are need to be developed by the user at the time of program writing.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description><link>http://bestutors.blogspot.com/2008/10/function-definition-function-and_04.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-6732431126602588518</guid><pubDate>Sun, 05 Oct 2008 05:43:00 +0000</pubDate><atom:updated>2008-10-04T22:55:00.849-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Function Declaration - Function and recursion</title><description>Before defining the function, it is desired to declare the function with its prototype.&lt;br /&gt;&lt;br /&gt;In function &lt;span style="font-weight: bold;"&gt;prototype&lt;/span&gt;, the return value of function, type, and number of argument are specified.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Function declaration is written in following ways:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;return data_type function_name (data_type argument 1, data_type argument 2 ................data_type argument n)&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;{&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;local variable declaration;&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;executable statement 1;&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;executable statement 2&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;..................................&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;................................&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;executable statement n;&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;return(expession);&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Note:&lt;/span&gt; An empty pair of parenthesis must follow the function name if the function definition does not include any arguments.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If it returns a float than command is:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;float f1(float arg 1, int arg 2);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;if it returns no value or return a character, then replace float by void or char respectively. If no arguments passed into a function than command is:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;char fun1 ( );&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;An example program using a small add function:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpoEFXxa4aNRzn_1yQqtb13ok0BgrhQkBv7p7RJ3QajPkZa76e9XvP3uue-lPmtXy4ylhyphenhyphenfEmhB4hHyk_2_2ynnfGl5o5eVj2eqQcAA7vVf5ACVbD3bfJ10DM3YS4vfKSkyXkG5C_f3FgV/s1600-h/c13_02_01.gif"&gt;&lt;img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpoEFXxa4aNRzn_1yQqtb13ok0BgrhQkBv7p7RJ3QajPkZa76e9XvP3uue-lPmtXy4ylhyphenhyphenfEmhB4hHyk_2_2ynnfGl5o5eVj2eqQcAA7vVf5ACVbD3bfJ10DM3YS4vfKSkyXkG5C_f3FgV/s400/c13_02_01.gif" alt="" id="BLOGGER_PHOTO_ID_5253542317312826514" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Out put of the program&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWEBqUUcHzIf49ublwdnYOczljTo9HTVHyA0XiBy8ynbBlNvYnePqRvAw_PekYS63txvlKd_P3DDeCf4ybKYpPPB3KrMuyCfPPdcuRFxFUI68DK9oRucNGQ8IQdW60b69T5phFOe0S5fa-/s1600-h/c13_02_02.gif"&gt;&lt;img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWEBqUUcHzIf49ublwdnYOczljTo9HTVHyA0XiBy8ynbBlNvYnePqRvAw_PekYS63txvlKd_P3DDeCf4ybKYpPPB3KrMuyCfPPdcuRFxFUI68DK9oRucNGQ8IQdW60b69T5phFOe0S5fa-/s400/c13_02_02.gif" alt="" id="BLOGGER_PHOTO_ID_5253542322909692498" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/div&gt;</description><link>http://bestutors.blogspot.com/2008/10/function-definition-function-and.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpoEFXxa4aNRzn_1yQqtb13ok0BgrhQkBv7p7RJ3QajPkZa76e9XvP3uue-lPmtXy4ylhyphenhyphenfEmhB4hHyk_2_2ynnfGl5o5eVj2eqQcAA7vVf5ACVbD3bfJ10DM3YS4vfKSkyXkG5C_f3FgV/s72-c/c13_02_01.gif" width="72"/><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-8665825417261244754</guid><pubDate>Sun, 05 Oct 2008 05:36:00 +0000</pubDate><atom:updated>2008-10-04T22:43:38.465-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Function Call - Function and Recursion</title><description>&lt;table border="0" cellpadding="0" cellspacing="0" width="535"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="linespadding"&gt;&lt;span class="textbold"&gt;Function &lt;/span&gt;can be called either by value or by reference .A function can be called by specifying its name followed by a list of arguments enclosed in &lt;span class="textbold"&gt;parentheses &lt;/span&gt;and separated by commas.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;From the above example the following line is used as a &lt;span class="textbold"&gt;function call:&lt;/span&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;sum=add(a,b); /* function call */&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;&lt;span class="textbold"&gt;Call by value: &lt;/span&gt;Call by value means  directly pass value within the function.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;An example program of call by value:&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmtjWw58aRdZ6N1s_LgFFGV1wYqlKRN_gWGhrhGfUbpSiUI7MFdzeAVkWhs7EhWi5Y_793gLv6PVXTQOAQZDWVynN-JkLDwIYsAuE1eHKH0wePszZcxSqO-wI8zWfCqjCfzmLk5SOKlufU/s1600-h/c13_03_01.gif"&gt;&lt;img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmtjWw58aRdZ6N1s_LgFFGV1wYqlKRN_gWGhrhGfUbpSiUI7MFdzeAVkWhs7EhWi5Y_793gLv6PVXTQOAQZDWVynN-JkLDwIYsAuE1eHKH0wePszZcxSqO-wI8zWfCqjCfzmLk5SOKlufU/s400/c13_03_01.gif" alt="" id="BLOGGER_PHOTO_ID_5253540058848427858" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Out put of the program            &lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbTDTTR-0npQCElpj7_Ji3IlbE7giG-sfBMX27yaWP7J4ELXtNK0r907XwL2tVk9gRg-QvOMzouPCEt7-XFRZ4QLUCF7phKkSGggQ3wLWcQ20r7Ie4w_RFyYqX-5d9SX2hDmAzjYXIEpw9/s1600-h/c13_03_02.gif"&gt;&lt;img style="cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbTDTTR-0npQCElpj7_Ji3IlbE7giG-sfBMX27yaWP7J4ELXtNK0r907XwL2tVk9gRg-QvOMzouPCEt7-XFRZ4QLUCF7phKkSGggQ3wLWcQ20r7Ie4w_RFyYqX-5d9SX2hDmAzjYXIEpw9/s400/c13_03_02.gif" alt="" id="BLOGGER_PHOTO_ID_5253540063538353922" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;table border="0" cellpadding="0" cellspacing="0" width="535"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;&lt;span class="textbold"&gt;Call by reference:&lt;/span&gt; Call by reference means sending the addresses of the argument to the called function.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;In this method the addresses of actual arguments in the calling function are copied into formal arguments of the called function. (later discussed in pointer section)&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold;"&gt;     &lt;td class="textbold"&gt;The Return Statement&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Information is returned from the function to the calling portion of the program via return statement.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;General form of return statement:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;return;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;or&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;return(expression);&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;Storage Classes&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;There are two different ways to characterize variables:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;1. By data type&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;2. By storage Class&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Data type refers to the type of information while storage class refers to the life time of a variable and its scope within the program.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;A variable in c can have any one of the four storage classes:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;1. Automatic Variable: &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;It is created when the function is called and destroy when the function is exited. Hence the name is Automatic. By default a variable is declared Automatic.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold;"&gt;     &lt;td class="textbold"&gt;2. External Variable:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;It is also known as Global Variable. This variables can be accessed from any function that falls within their scope.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold;"&gt;     &lt;td class="textbold"&gt;3. Static Variable:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;A static variable may be either internal or external type , depending on the place of declaration.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Internal static variable extends up to the function in which they are defined and external static variable is declared outside of all function and is available to all the functions in the program.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold;"&gt;     &lt;td class="textbold"&gt;4. Register Variable:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;We can tell the compiler that a variable should be kept in one of the machine's registers, instead of keeping in the memory (where normal variables are stored ). &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Since, a register access is much faster than a memory access and keeping the frequently accessed variables in the register will lead to faster execution of programs.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://bestutors.blogspot.com/2008/10/function-call-function-and-recursion.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmtjWw58aRdZ6N1s_LgFFGV1wYqlKRN_gWGhrhGfUbpSiUI7MFdzeAVkWhs7EhWi5Y_793gLv6PVXTQOAQZDWVynN-JkLDwIYsAuE1eHKH0wePszZcxSqO-wI8zWfCqjCfzmLk5SOKlufU/s72-c/c13_03_01.gif" width="72"/><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-179050133839519175</guid><pubDate>Sun, 05 Oct 2008 05:32:00 +0000</pubDate><atom:updated>2008-10-04T22:36:35.464-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Recursion - Function and Recursion</title><description>Repetitive calling of the same function is called &lt;span class="textbold"&gt;recursion&lt;/span&gt;. &lt;span class="textbold"&gt;Recursions&lt;/span&gt; are those functions which call itself again and again. Recursive functions can easily become &lt;span class="textbold"&gt;infinite loops.&lt;/span&gt;          &lt;br /&gt;          An example program to find out the factorial of any number is the one of the best example of recursion:&lt;br /&gt;&lt;br /&gt;         &lt;br /&gt;          &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgStKWFuds6yDV6cJgNKds-bvAs4vULs5NBDmeHa_EDtdR4zHTcEB5r04mN6C52_YoQrHVGuS2mYPO787mjzmJ_MQ3DgmDWYtMgq1caaAlFZXbe_IQmVpdW2OMOw5EESSr1SMvB2Y5HekO9/s1600-h/ser_right_bg.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgStKWFuds6yDV6cJgNKds-bvAs4vULs5NBDmeHa_EDtdR4zHTcEB5r04mN6C52_YoQrHVGuS2mYPO787mjzmJ_MQ3DgmDWYtMgq1caaAlFZXbe_IQmVpdW2OMOw5EESSr1SMvB2Y5HekO9/s400/ser_right_bg.gif" alt="" id="BLOGGER_PHOTO_ID_5253538894217483538" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;         &lt;br /&gt;          Out put of the program&lt;br /&gt;&lt;br /&gt;         &lt;br /&gt;          &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgOZiUMazhsCrqejrw8qLj_EcMuIPdXXrNJwBK1JOWWQY2HVQY3L6vzpMUfV_VezI47bZLuKJf54aTeCGxox0t8PF9i37C7cJXeobmj6OCmODNFz9KtzzN3EkM3oPyfs5UBlr-daNdx6_t/s1600-h/c13_04_02.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgOZiUMazhsCrqejrw8qLj_EcMuIPdXXrNJwBK1JOWWQY2HVQY3L6vzpMUfV_VezI47bZLuKJf54aTeCGxox0t8PF9i37C7cJXeobmj6OCmODNFz9KtzzN3EkM3oPyfs5UBlr-daNdx6_t/s400/c13_04_02.gif" alt="" id="BLOGGER_PHOTO_ID_5253538894327573666" border="0" /&gt;&lt;/a&gt;</description><link>http://bestutors.blogspot.com/2008/10/recursion-function-and-recursion.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgStKWFuds6yDV6cJgNKds-bvAs4vULs5NBDmeHa_EDtdR4zHTcEB5r04mN6C52_YoQrHVGuS2mYPO787mjzmJ_MQ3DgmDWYtMgq1caaAlFZXbe_IQmVpdW2OMOw5EESSr1SMvB2Y5HekO9/s72-c/ser_right_bg.gif" width="72"/><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-5323987378568126357</guid><pubDate>Sun, 05 Oct 2008 05:27:00 +0000</pubDate><atom:updated>2008-10-04T22:28:32.845-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Introduction - pointers</title><description>&lt;table border="0" cellpadding="0" cellspacing="0" width="535"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;&lt;span class="textbold"&gt;Pointers&lt;/span&gt; are a fundamental part of C. If you cannot use &lt;span class="textbold"&gt;pointers&lt;/span&gt; properly then you have basically lost all the power and flexibility that C allows. The secret of C is in its use of &lt;span class="textbold"&gt;pointers.&lt;/span&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;C uses pointers a lot. Why?&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;It is the only way to express some computations.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;It produces compact and efficient code.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;It provides a very powerful tool.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;C uses pointers explicitly with following:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;1. Functions.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;2. Arrays.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;3. Structures. (discussed later)&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;&lt;span class="textbold"&gt;Note:&lt;/span&gt; Pointers are perhaps the most difficult part of C to understand. C's implementation is slightly different from other languages.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="style5"&gt;What is a Pointer?&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;A &lt;span class="textbold"&gt;pointer&lt;/span&gt; is a variable which can hold the address of a memory location rather than the value at the location.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;Pointer Notation&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;The actual address of a variable is not known immediately. We can determine the address of the variable using address of &lt;span class="textbold"&gt;operator(&amp;amp;)&lt;/span&gt;.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt; We have already seen the use of address of &lt;span class="textbold"&gt;operator&lt;/span&gt; in the &lt;span class="textbold"&gt;scanf()&lt;/span&gt; function.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Another  &lt;span class="textbold"&gt;pointer operator&lt;/span&gt; available in C is &lt;span class="textbold"&gt;"*"&lt;/span&gt; called &lt;span class="textbold"&gt;"value of address"&lt;/span&gt; operator. It gives the value stored at a particular address. This operator is also known as indirection operator.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;Pointer Declaration&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;To declare a pointer to a variable:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;int *pointer;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;&lt;span class="textbold"&gt;Note: &lt;/span&gt;We must associate a pointer to a particular type: You can't assign the address of a &lt;span class="textbold"&gt;short int&lt;/span&gt; to a&lt;span class="textbold"&gt; long int&lt;/span&gt;,&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://bestutors.blogspot.com/2008/10/introduction-pointers.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-5266917976794389312</guid><pubDate>Sun, 05 Oct 2008 05:26:00 +0000</pubDate><atom:updated>2008-10-04T22:27:34.302-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Pointer expression - pointers</title><description>&lt;table style="text-align: left; margin-left: 0px; margin-right: 0px; width: 678px; height: 635px;" border="0" cellpadding="0" cellspacing="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="linespadding"&gt;Like other variables &lt;span class="textbold"&gt;pointer &lt;/span&gt;variable can also be used in expressions. &lt;span class="textbold"&gt;Arithmetic &lt;/span&gt;and &lt;span class="textbold"&gt;comparison&lt;/span&gt; operation can be performed on the pointers.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;Pointer Arithmetic&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;Example:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Addition of a number to a pointer &lt;span class="textbold"&gt;int i=4,*j,*&lt;/span&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;j=&amp;i;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;j=j+1;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;j=j+9;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;k=j+3;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;Example:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Subtraction of number from a pointer&lt;span class="textbold"&gt; int i=4,*j,*k&lt;/span&gt;;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;j=&amp;i;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;j=j-2;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;j=j-5;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;k=j-6;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;But the following operation are not allowed on pointers:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;a) multiplication of pointer with a constant&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;b) addition of two pointer&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;c) division of pointer with a constant&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;Pointer Comparison&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Pointer can be compared using &lt;span class="textbold"&gt;relational operator&lt;/span&gt;. Expression such as-&lt;span class="textbold"&gt; p1&gt;p2  p1=p2&lt;/span&gt; &lt;span class="textbold"&gt;p1!=p2 &lt;/span&gt;are allowed.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description><link>http://bestutors.blogspot.com/2008/10/pointer-expression-pointers.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-5108788424320421048</guid><pubDate>Sun, 05 Oct 2008 04:52:00 +0000</pubDate><atom:updated>2008-10-04T22:26:08.970-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Pointer &amp; functions - Pointers</title><description>Let us now examine the close relationship between pointers and C's other major parts. We will start with functions.&lt;br /&gt;&lt;br /&gt;When C passes arguments to functions it passes them by value.&lt;br /&gt;&lt;br /&gt;There are many cases when we may want to alter a passed argument in the function and receive the new value back once the function has finished.&lt;br /&gt;&lt;br /&gt;C uses pointers explicitly to do this.&lt;br /&gt;&lt;br /&gt;The best way to study this is to look at an example where we must be able to receive changed parameters. Let us try and write a function to swap variables around?&lt;br /&gt;&lt;br /&gt;The usual function call:&lt;br /&gt;&lt;br /&gt;swap (a, b) won't work.&lt;br /&gt;&lt;br /&gt;Pointers provide the solution: Pass the address of the variables to the functions and access address of function.&lt;br /&gt;&lt;br /&gt;Thus our function call in our program would look like this:&lt;br /&gt;&lt;br /&gt;swap (&amp;amp;a, &amp;amp;b)&lt;br /&gt;&lt;br /&gt;The Code to swap is fairly straightforward:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;void swap(int *px, int *py)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;{ int temp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;temp = *px;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;/* contents of pointer */&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;*px = *py;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;*py = temp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;}&lt;/span&gt;</description><link>http://bestutors.blogspot.com/2008/10/pointer-functions-pointers.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-4734262354365459761</guid><pubDate>Sun, 29 Jun 2008 16:22:00 +0000</pubDate><atom:updated>2008-06-29T09:29:46.502-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Pointer &amp; Array-Pointers</title><description>&lt;div style="text-align: justify;"&gt;&lt;span class="textbold"&gt;Pointers &lt;/span&gt;and &lt;span class="textbold"&gt;arrays &lt;/span&gt;are very closely linked in C.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="textbold"&gt;Hint:&lt;/span&gt; Think of array elements arranged in consecutive memory locations.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; Consider the following:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int a[10], x;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int *pa;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; pa = &amp;amp;a[0]; /* pa pointer to address of a[0] */&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; x = *pa;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; /* x = contents of pa (a[0] in this case) */&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;img src="http://education.ebizel.com/html/comp_courses/Programming%20Language/C/img/c14_04_01.gif" height="160" width="520" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="textbold"&gt;Warning:&lt;/span&gt; There is no bound checking of &lt;span class="textbold"&gt;arrays &lt;/span&gt;and &lt;span class="textbold"&gt;pointers&lt;/span&gt; so you can easily go beyond array memory and overwrite other things.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; C however is much more subtle in its link between &lt;span class="textbold"&gt;arrays&lt;/span&gt; and &lt;span class="textbold"&gt;pointers&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; For example we can just type:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; pa = a;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; instead of&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; pa = &amp;amp;a[0]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; and&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; a[i] can be written as *(a + i).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; i.e. &amp;amp;a[i] =a + i.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; We also express pointer addressing like this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; pa[i] =*(pa + i).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; However pointers and arrays are different:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; A pointer is a variable. We can do&lt;span class="textbold"&gt; pa = a and pa++&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; An Array is not a variable. &lt;span class="textbold"&gt;a = pa &lt;/span&gt;and &lt;span class="textbold"&gt;a++ ARE ILLEGAL&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; This stuff is very important. Make sure you understand it. We will see a lot more of this. We can now understand how arrays are passed to functions.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; When an array is passed to a function what is actually passed is its initial element location in memory&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; So: strlen(s) strlen(&amp;amp;s[0])&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; This is why we declare the function:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int strlen(char s[]);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; An equivalent declaration is:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int strlen(char *s);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; since &lt;span class="textbold"&gt;char s[] &lt;/span&gt;is equivalent to&lt;span class="textbold"&gt; char *s&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="textbold"&gt;strlen ()&lt;/span&gt; is a standard library function  that returns the length of a string.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; Let's look at how we may write a function:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; int strlength(char *s)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; {&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; char *p = s;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; while (*p != '\0');&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; p++;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; return p-s;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; Now let’s write a function to copy a string to another string. &lt;span class="textbold"&gt;strcpy ()&lt;/span&gt; is a standard library function that does this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; void strcopy (char *s, char *t)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; { while ( (*s++ = *t++) != `\0' );}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; This uses pointers and assignment by value.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="textbold"&gt;Note:&lt;/span&gt; Uses of Null statements with while.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; Malloc Library Function&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; Function: Allocates main memory&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; Syntax: void*malloc(size_t size);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; Prototype in: stdlib.h, alloc.h&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="textbold"&gt;Remarks: &lt;/span&gt;malloc allocates a block of size bytes from the C heap memory. It allows a program to allocate memory explicitly, as it is needed and in the exact amounts needed.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; Calloc Library Function&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; Function: Allocates main memory&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; Syntax: void*calloc(size_t n size);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; Prototype in: stdlib.h, alloc.h&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="textbold"&gt;Remarks: &lt;/span&gt;Calloc provides access to the C heap memory . Calloc allocates a block of size n items of x size. The block is cleared to 0.&lt;/div&gt;</description><link>http://bestutors.blogspot.com/2008/06/pointer-array-pointers.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-9211988246850915206</guid><pubDate>Sun, 29 Jun 2008 16:17:00 +0000</pubDate><atom:updated>2008-06-29T09:19:32.883-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Multi Dimensional Arrays &amp; Pointer-Pointers</title><description>&lt;table border="0" cellpadding="0" cellspacing="0" width="535"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="linespadding"&gt;We should think of multidimensional arrays in a different way in C:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;A 2D array is really a 1D array, each of whose elements is itself an array&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Hence&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;a[n][m] notation.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Array elements are stored row by row.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;When we pass a 2D array to a function we must specify the number of columns and the number of rows is irrelevant.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;The reason for this is pointers again. C needs to know how many columns in order that it can jump from row to row in memory.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Considerint &lt;span class="textbold"&gt;a[5][35]&lt;/span&gt; to be passed in a function:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;We can do:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;f(int a[][35]) {.....}&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;or even:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;f(int (*a)[35]) {.....}&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;We need parenthesis &lt;span class="textbold"&gt;(*a)&lt;/span&gt; &lt;span class="textbold"&gt;since [] &lt;/span&gt;have a higher precedence than &lt;span class="textbold"&gt;*&lt;/span&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;So:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;&lt;span class="textbold"&gt;int (*a)[35]; /*&lt;/span&gt;declares a pointer to an array of &lt;span class="textbold"&gt;35 int */&lt;/span&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;&lt;span class="textbold"&gt;int *a[35]; /*&lt;/span&gt;declares an array of 35 pointers to &lt;span class="textbold"&gt;int */&lt;/span&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Now lets look at the (subtle) difference between pointers and arrays. Strings are a common application of this.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Consider:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;char *name[10];&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;char Aname[10][20];&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;We can legally do&lt;span class="textbold"&gt; name[3][4]&lt;/span&gt; and &lt;span class="textbold"&gt;Aname[3][4]&lt;/span&gt; in C.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description><link>http://bestutors.blogspot.com/2008/06/multi-dimensional-arrays-pointer.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-2214212836894315663</guid><pubDate>Sun, 29 Jun 2008 16:16:00 +0000</pubDate><atom:updated>2008-06-29T09:16:51.222-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Arrays of Pointer-Pointers</title><description>&lt;table border="0" cellpadding="0" cellspacing="0" width="535"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="linespadding"&gt;We can have arrays of pointers since pointers are variables.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;&lt;span class="textbold"&gt;Example use:&lt;/span&gt; Sort lines of text of different length.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;&lt;span class="textbold"&gt;Note: &lt;/span&gt;Text can't be moved or compared in a single operation.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Arrays of Pointers are a data representation that will cope efficiently and conveniently with variable length text lines.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;&lt;span class="textbold"&gt;How can we do this: &lt;/span&gt;Store lines end-to-end in one big char array n will delimit lines.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Store pointers in a different array where each pointer points to 1st char of each new line.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Compare two lines using &lt;span class="textbold"&gt;strcmp () &lt;/span&gt;standard library function.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;If 2 lines are out of order swap pointer in pointer array (not text).&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://bestutors.blogspot.com/2008/06/arrays-of-pointer-pointers.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-909306669358544636</guid><pubDate>Sun, 29 Jun 2008 16:13:00 +0000</pubDate><atom:updated>2008-06-29T09:16:09.217-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Pointer &amp; functions -Pointers</title><description>&lt;table style="text-align: left; margin-left: 0px; margin-right: 0px;" border="0" cellpadding="0" cellspacing="0" width="535"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="linespadding"&gt;When an array is passed to a function as an argument , only the address of the first element of the array is passed , but not the actual values of the array elements.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;If&lt;span class="textbold"&gt; x&lt;/span&gt; is an array, when we call &lt;span class="textbold"&gt;sort(x)&lt;/span&gt;, the address of&lt;span class="textbold"&gt; x[0]&lt;/span&gt; is passed to the function&lt;span class="textbold"&gt; sort()&lt;/span&gt;. &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;The function uses this address for manipulating the array elements.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;The address of a variable can be passed as an argument to a function in the normal fashion. &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;When address is passed to a function , the parameters receiving the address should be pointers.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;The process of calling a function using pointer to pass the address of variable is known as call by reference.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;The function which is called by reference can change the value of the variable used in the call.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold;"&gt;     &lt;td class="textbold"&gt;Example:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold;"&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;main()&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;{&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;int x;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;x=20;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;change(&amp;amp;x);&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;printf("%d\n",x);&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;}&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;change( int *p)&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;{&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;*p=*p+10;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;}&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;&lt;span class="textbold"&gt;Explanation:&lt;/span&gt; When the function &lt;span class="textbold"&gt;change() &lt;/span&gt;is called, the address of the variable x, not its value, is passed into the function &lt;span class="textbold"&gt;change().&lt;/span&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Inside &lt;span class="textbold"&gt;change(),&lt;/span&gt; the value at which p points is incremented by 10 , and the changed value is then displayed in the main function.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description><link>http://bestutors.blogspot.com/2008/06/pointer-functions-pointers.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-7981936318411865461</guid><pubDate>Sun, 29 Jun 2008 16:09:00 +0000</pubDate><atom:updated>2008-06-29T09:13:38.480-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Introduction-Structures</title><description>&lt;table style="text-align: left; margin-left: 0px; margin-right: auto;" border="0" cellpadding="0" cellspacing="0" width="535"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="linespadding"&gt;The C language allows us to create custom data types.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;The structure is a custom data type which c combines different data types .&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;The structure is a custom data type which combine different data types to form a new user define data type.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold;"&gt;     &lt;td class="style5"&gt;Definition&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;A structure is a collection of variable reference under one name providing a convincible means of related information together.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="textbold"&gt;Format: struct tag_name&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;{&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;data _type member1;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;data_type member2;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;-------------------&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;---------------------&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;};&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;here a keyboard struct declares a structes to hold the details of field of different data types.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="textbold"&gt;Example:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="textbold"&gt;struct addr&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;{&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;char name [30];&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;char city [15];&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;int pincode ;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;};&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="textbold"&gt;Creating Structure variable&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;structure can be created in two ways:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;1. declaration using tagname anywhere in the program.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="textbold"&gt;Example:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="textbold"&gt;struct book&lt;/td&gt;   &lt;/tr&gt;      &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;{&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;char name [30];&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;char author [25];&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;float price;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;};&lt;/td&gt;   &lt;/tr&gt;      &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="textbold"&gt;struct book book1 book2&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;2. it is also allowed to combine structure declaration and variable declaration in one statement.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="textbold"&gt;Example:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="textbold"&gt;struct person&lt;/td&gt;   &lt;/tr&gt;      &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;{&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;char *name;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;int age;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;char*address;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;};&lt;/td&gt;   &lt;/tr&gt;      &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="textbold"&gt;p1,p2,p3&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;while declaring structure variable along with their definition, the use of tag-name is optional.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="textbold"&gt;Struct&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;{&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;char *name;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;int age;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;char * address;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="TDpadding"&gt;}&lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold; color: rgb(255, 102, 0);"&gt;     &lt;td class="textbold"&gt;p1,p2,p3&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold;"&gt;     &lt;td class="textbold"&gt;Image showing how the given value allocate in structure with the help of an example &gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td align="center"&gt;&lt;img src="http://education.ebizel.com/html/comp_courses/Programming%20Language/C/img/c15_01_01.gif" border="1" height="401" width="390" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description><link>http://bestutors.blogspot.com/2008/06/introduction-structures.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-6395212533253857544</guid><pubDate>Sun, 29 Jun 2008 16:07:00 +0000</pubDate><atom:updated>2008-06-29T09:09:22.833-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Giving values to member-Structures</title><description>&lt;table style="text-align: left; margin-left: 0px; margin-right: 0px;" border="0" cellpadding="0" cellspacing="0" width="535"&gt;&lt;tbody&gt;&lt;tr align="justify"&gt;&lt;td class="linespadding"&gt;The link between a member and a variable is established using member operator `.' to dot operator.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr align="justify"&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr align="justify"&gt;     &lt;td class="textbold"&gt;An example program to define a structure and assign value to members:&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td align="center"&gt;&lt;img src="http://education.ebizel.com/html/comp_courses/Programming%20Language/C/img/c15_02_01.gif" border="1" height="372" width="520" /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="textbold"&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Out put of the program&lt;/span&gt;&lt;/div&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td align="center"&gt;&lt;img src="http://education.ebizel.com/html/comp_courses/Programming%20Language/C/img/c15_02_02.gif" border="1" height="163" width="520" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description><link>http://bestutors.blogspot.com/2008/06/giving-values-to-member-structures.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-6084431285038142456</guid><pubDate>Sun, 29 Jun 2008 16:05:00 +0000</pubDate><atom:updated>2008-06-29T09:07:02.697-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Structure Initialization-Structures</title><description>&lt;div style="text-align: justify;"&gt;a structure variable can be initialization as any other data type.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;Main()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;static struct&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;int weight;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;float height;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;student{560,080,75};&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This assign the value 60 to student weight and 180.75 student height. there is a one to one correspondents between the members and their initializing values.&lt;br /&gt;&lt;br /&gt;The following statements initialize two structures variables:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;Main()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;Struct st_decord&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;int weight;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;float height;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;static struct st_record student2={53, 170,60}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;another method is to initlialize a structure variable outside the function.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;Struct st_record/* No static word*/&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;int weight;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;int height&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;student={60,50,75}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;main()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;static struct st_record student2={53,170,60}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;}&lt;/span&gt;&lt;/div&gt;</description><link>http://bestutors.blogspot.com/2008/06/structure-initialization-structures.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-774923514838651066</guid><pubDate>Sun, 29 Jun 2008 16:02:00 +0000</pubDate><atom:updated>2008-06-29T09:03:07.912-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Comparison of structure variables-Structures</title><description>&lt;table style="text-align: left; margin-left: 0px; margin-right: 0px;" border="0" cellpadding="0" cellspacing="0" width="535"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="linespadding"&gt;Two variables of the same structure type can be compared the same way as ordinary variables.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="TDpadding"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;operation meaning&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="TDpadding"&gt;&lt;br /&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;person1=person2*assign perosn2 to person1&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="TDpadding"&gt;&lt;br /&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;person1== person2*compare all name of person1 and person2 and return1&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description><link>http://bestutors.blogspot.com/2008/06/comparison-of-structure-variables.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-6518442700553683975</guid><pubDate>Sun, 29 Jun 2008 15:57:00 +0000</pubDate><atom:updated>2008-06-29T09:01:44.843-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Arrays of structures-structure</title><description>&lt;table style="text-align: left; margin-left: 0px; margin-right: 0px;" border="0" cellpadding="0" cellspacing="0" width="535"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="linespadding"&gt;The most common use of structures is in arrays of structures. To declare an array of structures, first the structure is defined then an array variable of that structure is declared.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr style="font-weight: bold;"&gt;     &lt;td class="textbold"&gt;E.g.: struct class student [100];&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;It defines an array called student which consists of 100 elements of structure named class.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Ans is stored inside the memory in the same way as a multidimensional array example program.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;To implements on array of structures.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description><link>http://bestutors.blogspot.com/2008/06/arrays-of-structures-structure.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-1143454316945875064</guid><pubDate>Sun, 29 Jun 2008 15:41:00 +0000</pubDate><atom:updated>2008-06-29T08:56:44.085-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Arrays with in structures-Structures</title><description>&lt;table style="text-align: left; margin-left: 0px; margin-right: 0px;" border="0" cellpadding="0" cellspacing="0" width="535"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="linespadding"&gt;Single as multidimensional arrays of type &lt;span class="textbold"&gt;int&lt;/span&gt; as &lt;span class="textbold"&gt;float&lt;/span&gt; can be defined as structure members.&lt;/td&gt;   &lt;/tr&gt;      &lt;tr style="font-weight: bold;"&gt;     &lt;td class="textbold"&gt;Example:&lt;/td&gt;   &lt;/tr&gt;      &lt;tr&gt;     &lt;td class="TDpadding"&gt;struct marks&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="TDpadding"&gt;{&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="TDpadding"&gt;int number;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="TDpadding"&gt;float subject[3];&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="TDpadding"&gt;}&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="TDpadding"&gt;student [2];&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;Here the member subject contains three elements,&lt;span class="textbold"&gt; subject[0], subject[1]&lt;/span&gt; and &lt;span class="textbold"&gt;subject[2] &lt;/span&gt;there elements can be accessed using appropriate subscript.&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td&gt; &lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;     &lt;td class="linespadding"&gt;For instance, the name &lt;span class="textbold"&gt;student [1] student [2]; &lt;/span&gt;would refer to the marks obtained in the third subject by the secured student.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</description><link>http://bestutors.blogspot.com/2008/06/arrays-with-in-structures-structures.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-3948284027130177805</guid><pubDate>Thu, 22 May 2008 13:29:00 +0000</pubDate><atom:updated>2008-05-22T07:14:07.056-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Structures with in structures-Structures</title><description>&lt;div style="text-align: justify;"&gt;Structures within a structure means nesting of structures.                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example:&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;struct salary           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;{           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;char name [20];           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;char department [10];           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;int basic-pay;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;int dearness-allowance;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;int huse_rent_allowance;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;int city_allowance;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;}           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;employee;                       &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This structure defines name, department, basic pay and three kinds of allowances.                      &lt;br /&gt;&lt;br /&gt;All the items related to allowance can be grouped together and declared under a sub-stricture. As shown below, strut salary                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;{           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;char name []2;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;char department [10];           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;struct;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt; int dearness;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;int house_rent;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;int city;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;[allowance;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;}           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;employee's;&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;The salary structure contains a member named allowance which use is a structures with.                       &lt;br /&gt;&lt;br /&gt;Three members.&lt;span class="textbold"&gt; &lt;span style="font-weight: bold;"&gt;Now ;&lt;/span&gt;&lt;/span&gt; the member compared in the inner &lt;span class="textbold"&gt;&lt;span style="font-weight: bold;"&gt;structure;&lt;/span&gt;,&lt;/span&gt; &lt;span style="font-weight: bold;" class="textbold"&gt;namely, ;dearness,&lt;/span&gt; &lt;span style="font-weight: bold;" class="textbold"&gt;house_rent &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;and city &lt;/span&gt;&lt;span class="textbold"&gt;&lt;span style="font-weight: bold;"&gt;can&lt;/span&gt; ;&lt;/span&gt;be left to &lt;span style="font-weight: bold;" class="textbold"&gt;as;&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;employee. ;allowance. Dearness           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;employee. Allowance. House_rent           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;employee allowance. city&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;The inner most member in a nested structure can be accessed by chaining all the concerned structure variables (from outermost to inner most) with the member using dot operator.            &lt;/div&gt;</description><link>http://bestutors.blogspot.com/2008/05/structures-with-in-structures.html</link><thr:total>1</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-2124239708336984114</guid><pubDate>Thu, 22 May 2008 13:22:00 +0000</pubDate><atom:updated>2008-05-22T06:28:13.070-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Passing structure to function-Structures</title><description>&lt;div style="text-align: justify;"&gt;There are three methods by which the values of structure can be transferred from one function to another:                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1&lt;/span&gt;. The first method is to pass each member of the structure as an actual argument of the function call.                       &lt;br /&gt;&lt;br /&gt;The actual argument is then treated independently like ordinary variables.                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2&lt;/span&gt;. The second methods involve passing of a copy of the entire structure to the called function                       &lt;br /&gt;&lt;br /&gt;Since the function is working on a copy of the entire structure to the called function,&lt;br /&gt;&lt;br /&gt;changes are not reflected in the original structure (in the calling function).                      &lt;br /&gt;&lt;br /&gt;It is necessary for the entire function to return the entire structure back to the calling function.                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3&lt;/span&gt;. The third approach employs a concept called pointers to pass the structure as an argument .                       In this case,&lt;br /&gt;&lt;br /&gt;the address location of the structure is passed to the called function.                       &lt;br /&gt;&lt;br /&gt;The function can access indirectly the entire structure and work on it.                      &lt;br /&gt;&lt;br /&gt;The general format of sending a copy of structure to the called function is:                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;function_name (structure_variable_name)&lt;/span&gt;&lt;/div&gt;</description><link>http://bestutors.blogspot.com/2008/05/passing-structure-to-function.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-6732724999400382333</guid><pubDate>Thu, 22 May 2008 13:08:00 +0000</pubDate><atom:updated>2008-05-22T06:19:27.822-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Introduction-Union</title><description>&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;Union&lt;/span&gt; are derived data types, the way structure are. Though, unions and structures look alike, and there is a fundamental difference.                      &lt;br /&gt;&lt;br /&gt;While structure enables you to create a number of different variables stored in difference places in memory, unions enable you to treat the same space as a number of different variables                       &lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Union-Definition and Declaration&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;Unions, like structures, contain members whose individual data types may differ from one another.                      &lt;br /&gt;&lt;br /&gt;However, the members within a union all share the some storage space within the computer's memory, whereas each member within a structure is assigned its own unique storage area.                      &lt;br /&gt;&lt;br /&gt;Thus, unions are used to conserve memory.                      &lt;br /&gt;&lt;br /&gt;They are useful for applications involving multiple members, where values need not be assigned to all of the members at any one time.                      &lt;br /&gt;&lt;br /&gt;Within a union, the bookkeeping required to store members whose data types are different (having different memory requirements) is handled automatically to the compiler.                      &lt;br /&gt;&lt;br /&gt;However, the user must keep track of what type of information is stored at any given time.                      &lt;br /&gt;&lt;br /&gt;An attempt to access the wrong type of information will produce meaningless results. In general terms, the composition of a union may be defined as:                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;Union tag           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;{           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;Member 1;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;Member 2;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;…..           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;member n;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;};                       &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Where union is  required keyword and the other terms have the same meaning as in a structure definition.                      &lt;br /&gt;&lt;br /&gt;Individual union variables can then be declared as:           storage-class union tag &lt;span class="textbold"&gt;&lt;span style="font-weight: bold;"&gt;variable 1, variable 2, . . . , variable n;&lt;/span&gt;&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;Where storage-class is an optional storage class specified, union is a required keyword, tag is the name that appears in the union definition, and variable 1, variable 2, . . . , variable n are union.&lt;br /&gt;&lt;br /&gt; The two declarations may be combined, just as we did with structures. Thus, we can write &lt;span style="font-weight: bold;" class="textbold"&gt;Storage-class union tag&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;{           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;Member 1;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;Member 2;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;. . . . .           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;member n;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 102, 0);"&gt;}                       &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The tag is optional in this type of declaration.                      &lt;br /&gt;&lt;br /&gt;&lt;span class="textbold"&gt;&lt;span style="font-weight: bold;"&gt;Notice that&lt;/span&gt;&lt;/span&gt; the union and structure declarations are external to the program functions, but the structure variable is defined locally within each function.              &lt;/div&gt;</description><link>http://bestutors.blogspot.com/2008/05/introduction-union.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-4080355834554874501</guid><pubDate>Thu, 22 May 2008 12:53:00 +0000</pubDate><atom:updated>2008-05-22T05:54:46.403-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Accessing a union member-Union</title><description>&lt;div style="text-align: justify;"&gt;To access a union member, you can use the same syntax that you use for structure members.                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;code.m, code.x etc.&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;During execution, we should make sure that the value of accessing member is currently stored.&lt;/div&gt;</description><link>http://bestutors.blogspot.com/2008/05/accessing-union-member-union.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-6032438942536915098</guid><pubDate>Thu, 22 May 2008 12:41:00 +0000</pubDate><atom:updated>2008-05-22T05:48:16.915-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Initialization of Union variable-Union</title><description>&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;A &lt;span style="font-weight: bold;"&gt;union&lt;/span&gt; variable can be initialized , provided its storage class is either external or static.                 &lt;br /&gt;&lt;br /&gt;Only one member of a union can be assigned a value at any one time.                    &lt;br /&gt;&lt;br /&gt;The initialization value is assigned to the first member within the union.                 &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;An example program to demonstrate initialization of union variables:&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYMiFfRZ0-aOdYoxWqQuQYY4lRnWat7pNpoB28DxVMCEUjAw7DwEhsUpNZnc7_viyHKTku5rkBKc3zzB9d32LekB7wyX5Fkdkft6FVH7BtHHbYBhF2oUeLMTwpSycap8lNti87pND7rnoS/s1600-h/c16_03_01.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYMiFfRZ0-aOdYoxWqQuQYY4lRnWat7pNpoB28DxVMCEUjAw7DwEhsUpNZnc7_viyHKTku5rkBKc3zzB9d32LekB7wyX5Fkdkft6FVH7BtHHbYBhF2oUeLMTwpSycap8lNti87pND7rnoS/s400/c16_03_01.gif" alt="" id="BLOGGER_PHOTO_ID_5203182194773691826" border="0" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://bestutors.blogspot.com/2008/05/initialization-of-union-variable-union.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYMiFfRZ0-aOdYoxWqQuQYY4lRnWat7pNpoB28DxVMCEUjAw7DwEhsUpNZnc7_viyHKTku5rkBKc3zzB9d32LekB7wyX5Fkdkft6FVH7BtHHbYBhF2oUeLMTwpSycap8lNti87pND7rnoS/s72-c/c16_03_01.gif" width="72"/><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-8394729782842792297</guid><pubDate>Thu, 22 May 2008 12:38:00 +0000</pubDate><atom:updated>2008-05-22T05:41:08.798-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Uses of Union-Union</title><description>&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;" class="textbold"&gt;Union&lt;/span&gt;, like structure, contain members whose individual &lt;span style="font-weight: bold;" class="textbold"&gt;data type&lt;/span&gt; may differ to each other.&lt;br /&gt;&lt;br /&gt;But the members that compose a &lt;span class="textbold"&gt;&lt;span style="font-weight: bold;"&gt;union&lt;/span&gt; &lt;/span&gt;share the same storage area within the computer's memory, whereas each member within a structure is assigned its own unique storage area.                      &lt;br /&gt;&lt;br /&gt;Thus, &lt;span style="font-weight: bold;" class="textbold"&gt;union&lt;/span&gt; are used to conserve memory.                      &lt;br /&gt;&lt;br /&gt;1. &lt;span style="font-weight: bold;" class="textbold"&gt;Unions&lt;/span&gt; are useful for application involving multiple members, where value need not to be assigned to all of the members at any one time.                      &lt;br /&gt;&lt;br /&gt;2. &lt;span style="font-weight: bold;" class="textbold"&gt;Unions&lt;/span&gt; are useful whenever there is a  requirement  to access the same memory location in more than one way. etc.&lt;/div&gt;</description><link>http://bestutors.blogspot.com/2008/05/uses-of-union-union.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-7370931917763664578.post-7562592781974985573</guid><pubDate>Thu, 22 May 2008 12:28:00 +0000</pubDate><atom:updated>2008-05-22T05:37:49.783-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C programming</category><title>Linked list-Dynamic Data Structure</title><description>&lt;div style="text-align: justify;"&gt;Before talking about the different mechanism of data structure we will take a short view of &lt;span class="textbold"&gt;&lt;span style="font-weight: bold;"&gt;DMA (Dynamic Memory Allocation)&lt;/span&gt;.&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;&lt;span class="textbold"&gt;&lt;span style="font-weight: bold;"&gt;DMA:&lt;/span&gt; &lt;/span&gt;C language requires the number of elements in an array to be specified at compile time.                       &lt;br /&gt;&lt;br /&gt;But it is not practically possible with &lt;span class="textbold"&gt;&lt;span style="font-weight: bold;"&gt;Array&lt;/span&gt;.&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;In &lt;span style="font-weight: bold;" class="textbold"&gt;array&lt;/span&gt; we allocate the memory first and then start using it.                      &lt;br /&gt;&lt;br /&gt;This may result in failure of a program or wastage of memory space.                      &lt;br /&gt;&lt;br /&gt;The concept of dynamic memory allocation can be used to eradicate this problem.                      &lt;br /&gt;&lt;br /&gt;In this technique , the allocation of memory is done at run time.                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;C language&lt;/span&gt; provides four library function known as memory management function that can be used for allocating and freeing memory during program execution.                      &lt;br /&gt;&lt;br /&gt;These are:                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;" class="textbold"&gt;malloc:&lt;/span&gt; allocate memory and return a pointer to the first byte of allocated space.                      &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example:&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ptr=(cast.type*)malloc(byte_size);&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;&lt;span class="textbold"&gt;&lt;span style="font-weight: bold;"&gt;calloc&lt;/span&gt;: &lt;/span&gt;allocates the memory spaces, initialize them to zero and returns pointer to first byte.                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ptr=(cast_type*)calloc(n.elem_size);&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;free: frees previously allocated space.                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example:&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;free(ptr);                       &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;span class="textbold"&gt;&lt;span style="font-weight: bold;"&gt;realloc&lt;/span&gt;:&lt;/span&gt; modifies the size of previously assigned space                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example:&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ptr=realloc(ptr,newsize);&lt;/span&gt;                      &lt;br /&gt;&lt;br /&gt;We studied about Array there we can observe one major disadvantage of Array is ,if an array is not filled by value, then memory will be locked up.                      &lt;br /&gt;&lt;br /&gt;To overcome this problem we use  Linked lists and other data structure mechanism.                      &lt;br /&gt;&lt;br /&gt;Linked List are a way to store data with structures so that the programmer can automatically create a new place to store data whenever necessary.                      &lt;br /&gt;&lt;br /&gt;Specifically, the programmer writes a struct definition that contains variables holding information about something, and then has a pointer to a struct of its type.                      &lt;br /&gt;&lt;br /&gt;Each of these individual struct in the list is known as a node.                       Think of it like a train. The programmer always stores the first node of the list.&lt;br /&gt;&lt;br /&gt;This would be the engine of the train.                      &lt;br /&gt;&lt;br /&gt;The pointer is the connector between cars of the train.                      &lt;br /&gt;&lt;br /&gt;Every time the train add a car, it uses the connectors to add a new car.                       &lt;br /&gt;&lt;br /&gt;This is like a programmer using the keyword new to create a pointer to a new struct                      &lt;br /&gt;&lt;br /&gt;In memory it is often described as looking like this:                      &lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;---------- ----------           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;- Data - &gt;- Data -&gt;           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;---------- - ----------           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;- Pointer- - - - Pointer-           &lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;---------- ----------&lt;/span&gt;&lt;/div&gt;</description><link>http://bestutors.blogspot.com/2008/05/linked-list-dynamic-data-structure.html</link><thr:total>0</thr:total><author>noreply@blogger.com (Jignesh Chheda)</author></item></channel></rss>