<?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-3867981276624493782</atom:id><lastBuildDate>Fri, 08 Nov 2024 15:37:34 +0000</lastBuildDate><category>Archive</category><category>Basics</category><category>Data Types</category><category>Get to Know Us</category><category>float</category><category>int</category><category>variables</category><title>C programming for Non programmers</title><description></description><link>http://mycodedotc.blogspot.com/</link><managingEditor>noreply@blogger.com (Anonymous)</managingEditor><generator>Blogger</generator><openSearch:totalResults>28</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><language>en-us</language><itunes:explicit>no</itunes:explicit><itunes:subtitle/><itunes:owner><itunes:email>noreply@blogger.com</itunes:email></itunes:owner><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-805419940347339369</guid><pubDate>Wed, 20 Aug 2014 07:09:00 +0000</pubDate><atom:updated>2013-08-24T20:21:51.044+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Get to Know Us</category><title>Why Read this Blog ?</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;blockquote class="tr_bq"&gt;
&lt;span style="background-color: white; color: #181818; font-family: georgia, serif; font-size: 14px; line-height: 18px;"&gt;“The more that you read, the more things you will know. The more that you learn, the more places you'll go.&lt;b&gt;”&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style="background-color: white; color: #181818; font-family: georgia, serif; font-size: 14px; line-height: 18px;"&gt;―&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.goodreads.com/author/show/61105.Dr_Seuss" style="background-color: white; color: #666600; font-family: georgia, serif; font-size: 14px; line-height: 18px; text-decoration: none;"&gt;Dr. Seuss&lt;/a&gt;&lt;i style="background-color: white; color: #181818; font-family: georgia, serif; font-size: 14px; line-height: 18px;"&gt;&lt;/i&gt;&lt;/blockquote&gt;
&lt;br /&gt;
Tired of reading books and searching the internet? Bored of listening to people talk about it while you&amp;nbsp;don't&amp;nbsp;understand a word they say?&lt;br /&gt;
&lt;br /&gt;
This blog is just for you.&lt;br /&gt;
&lt;br /&gt;
C is one of the most used computer languages and one of the best ones to begin your&amp;nbsp;programming career. More reasons to learn it are:&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;b&gt;&lt;em style="background-color: white; font-family: arial, sans-serif; font-size: small; font-style: normal; line-height: 16px;"&gt;C is one of the most widely used programming languages of all time&amp;nbsp;&lt;/em&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;span style="background-color: white; color: #303030; font-family: verdana; font-size: 12px; line-height: 20px; margin: 0px; padding: 0px;"&gt;C is great for putting ideas into practice&lt;/span&gt;&lt;span style="background-color: white; color: #303030; font-family: verdana; font-size: 12px; line-height: 20px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;span style="background-color: white; color: #303030; font-family: verdana; font-size: 12px; line-height: 20px; margin: 0px; padding: 0px;"&gt;Closeness to the Machine&lt;/span&gt;&lt;span style="background-color: white; color: #303030; font-family: verdana; font-size: 12px; line-height: 20px;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style="background-color: white; color: #303030; font-family: verdana; font-size: 12px; line-height: 20px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;When you are working with C, you are working with various aspects like individual bits,&lt;/span&gt;&lt;span style="background-color: white; color: #303030; font-family: verdana; font-size: 12px; line-height: 20px;"&gt;&amp;nbsp;pointers,&lt;/span&gt;&lt;span style="background-color: white; color: #303030; font-family: verdana; font-size: 12px; line-height: 20px;"&gt;&amp;nbsp;and bytes.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;span style="background-color: white; color: #303030; font-family: verdana; font-size: 12px; line-height: 20px;"&gt;&lt;b&gt;Easy to Learn&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;b style="color: #303030; font-family: verdana; font-size: 12px; line-height: 20px;"&gt;Concepts learnt in C can be extended to other other programming languages&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style="background-color: white; color: #303030; font-family: verdana; font-size: 12px; line-height: 20px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Most of the new&amp;nbsp;programming&amp;nbsp;languages are influenced by C.&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="color: #303030; font-family: verdana;"&gt;&lt;span style="font-size: 12px; line-height: 20px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&amp;nbsp;While some of us are willing to learn but&amp;nbsp;don't&amp;nbsp;know where to start, others are forced into it. There are thousands of books each&amp;nbsp;with&amp;nbsp;millions of examples that&amp;nbsp;you&amp;nbsp;don't&amp;nbsp;seem to understand and doubts you&amp;nbsp;don't&amp;nbsp;know whom to ask. Hence i have started this blog to share what ever i have learnt about C programming in the last 4 years. This blog is&amp;nbsp;intended&amp;nbsp;for the ones who have no prior knowledge of computer programming and also for the ones who what to learn more.&lt;br /&gt;
&lt;br /&gt;
Before we start programming there are a few rules for this blog which will help u traverse the posts easily.&lt;br /&gt;
&lt;a href="http://mycodedotc.blogspot.in/2012/08/so-what-are-rules.html"&gt;Check the next post by clicking here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
For those who want to know more on which books to refer, i recommend &lt;a href="http://www.flipkart.com/c-programming-language-8120305965/p/itmdytcjjypxjvwf?pid=9788120305960&amp;amp;affid=ryanlogsya"&gt;The C Programming Language (Ansi C Version)&lt;/a&gt;.&amp;nbsp;This is the cheapest book one can find and written by the person who created the C language.&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2012/08/why-read-this-blog.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-1439772002072012126</guid><pubDate>Sun, 06 Oct 2013 05:54:00 +0000</pubDate><atom:updated>2013-10-09T20:44:54.313+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Data Types</category><category domain="http://www.blogger.com/atom/ns#">float</category><title>Float Data Type</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiLgZ8Knkj3KWyYLmjgXd7iJDez3ILzL4zig7YEk3WN7K4997TsqdDY7McQaMtmiypwRL5BZ4FxoAKTrf3sPLcEvyr8Lnkstt12qUJ7e4Wqw5IcgcgIJ0x1f4wUdSofAZocWYzhYUpKeo/s1600/float+LOGO.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img alt="Float Data Type" border="0" height="213" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiLgZ8Knkj3KWyYLmjgXd7iJDez3ILzL4zig7YEk3WN7K4997TsqdDY7McQaMtmiypwRL5BZ4FxoAKTrf3sPLcEvyr8Lnkstt12qUJ7e4Wqw5IcgcgIJ0x1f4wUdSofAZocWYzhYUpKeo/s640/float+LOGO.jpg" title="Float Data Type" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The float is the second most commonly used data type used in C and allows you to store decimal numbers.&lt;br /&gt;
You can use float data types to store results of operations involving a division operation. Before we start with an example lets learn more about it.&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;
Why is float 4 Bytes long ?&lt;/h3&gt;
&lt;br /&gt;
As you may remember int is only 2 Bytes long(for 16 bit CPU, 4 Bytes for 32 bit CPU). So what makes float so special to require twice the amount of space?&lt;br /&gt;
&lt;br /&gt;
In a decimal number, its important to know the position of the decimal point. Consider this example:&lt;br /&gt;
129 &amp;lt; 1290 &amp;nbsp;, but 1.29 = 1.29. Similarly 1.29 &amp;lt; 12.9.&lt;br /&gt;
&lt;br /&gt;
The placement of the decimal point decides the value of the number and this is done in the following manner.&lt;br /&gt;
Lets consider &lt;b&gt;3.141592&lt;/b&gt; as an example.&lt;br /&gt;
&lt;br /&gt;
This number can be written as 3141592 x 10&lt;sup&gt;-5&lt;/sup&gt;. This value is separated as 3141592 and -5.&lt;br /&gt;
3141592 is called the &lt;b&gt;exponent&lt;/b&gt;, -5 the &lt;b&gt;mantissa.&lt;/b&gt;&amp;nbsp;The compiler then makes use of these values and encodes the float representation using the &lt;a href="http://meseec.ce.rit.edu/eecc250-winter99/250-1-27-2000.pdf" target="_blank"&gt;IEEE 754 standard&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
As we need to store the information of two integers to represent a single float it requires twice the amount of space. and hence 4 Bytes of memory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lets continue with the example to know more about float.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;/*
    Author: Ryan Sequeira
    Title:  Float data type formatting
*/

#include &amp;lt;stdio.h&amp;gt;

int main()
{
    float n = 22.0f, d = 7.0f;
    float pi = n/d;
    
    //print the value of pi
    printf("The value of Pi: %18f\n", pi);    
    
    //print the first 2 decimals of pi
    printf("Pi with first 2 decimals: %5.2f\n", pi); 
    
    //print the first 20 decimals of pi
    printf("Pi with first 20 decimals: %.20f\n", pi);
    
    /* float prints 6 decimal places by default 
    and gives a accuracy upto 20 decimal places. */
    
    //print the first 25 decimals of pi
    printf("Pi with first 25 decimals: %.25f\n", pi);
  
    return 0;
}
&lt;/pre&gt;
&lt;br /&gt;
Lets &amp;nbsp;understand how formatting works with float.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLDoHJHBki0zkg95bHSaVx-lK4B0FRDFoZzEv7-FTfn_XdTSDT1oLQ62htovsVslUYmLKthJ97bfq9fURKqBMl8d1VXSQLvibrP3cG55E4JYboMoQKluKll9HxL_7daw-EIS1EchvPqiA/s1600/floatff.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img alt="float output for %5.2f" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLDoHJHBki0zkg95bHSaVx-lK4B0FRDFoZzEv7-FTfn_XdTSDT1oLQ62htovsVslUYmLKthJ97bfq9fURKqBMl8d1VXSQLvibrP3cG55E4JYboMoQKluKll9HxL_7daw-EIS1EchvPqiA/s1600/floatff.png" title="float output for %5.2f" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;float output for %5.2f&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
We use %5.2f to print the above result. In this example &lt;b&gt;5 represents the number of places to reserve&lt;/b&gt; for the decimal and &lt;b&gt;.2 represents the number of decimal digits to output&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
The number before the decimal point ( in %5.2f ) represents minimum number of blocks to reserve for the value, and the number after the decimal decides the number of places to round off the decimal.&lt;br /&gt;
&lt;br /&gt;
You can try this with integers too. But since there isn't a decimal here you can only use an integer value between % and d.&lt;br /&gt;
&lt;br /&gt;
Example &amp;nbsp;printf("%5d",100); will reserve 5 blocks for the value 100. You can use this formatting option to right align your results.&lt;br /&gt;
&lt;br /&gt;
Now that we have learnt a lot about float lets write a small program that converts temperature in Fahrenheit to Celsius and Kelvin. &lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;/*
    Author: Ryan Sequeira
    Title:  Program to convert temperature in
            Fahrenheit to Celsius and Kelvin
*/

#include &amp;lt;stdio.h&amp;gt;

int main()
{
   //declaring variables to store temperatures 
   float far = 0.0f;
   float cel = 0.0f;
   float kel = 0.0f;
   
   printf("Enter the temperature (in Fahrenheits): ");
   scanf("%f",&amp;amp;far);
   
   //formulas to convert Fahrenheit to Celsius 
   cel = (far - 32) * (5.0f/9.0f);
   
   //formula to convert Fahrenheit to Kelvin
   kel = (far + 459.67f) * (5.0f/9.0f);
   
   printf("%.2f Fahrenheits equals \n %7.2f Celsius and \n %7.2f Kelvin\n", far, cel, kel);
   
   return 0;
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;!-- CSS goes in the document HEAD or added to your external stylesheet --&gt;
&lt;style type="text/css"&gt;
   table.gridtable {
   font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
   font-size: 13px;
   text-align: left;
   color:#333333;
   border-width: 0px;
   border-color: #FFFFFF;
   border-collapse: collapse;
   cellspacing: 50px;
   }
   table.gridtable th {
   padding: 8px;
   border-style: solid;
   border-width: 0px 1px 0px 1px;
   border-color: #E6E6E6;
   background-color: #FFCC00 ;
   }
   table.gridtable td {
   border-width: 1px;
   padding: 8px;
   border-style: solid;
   border-color: #CFCFCF;
   background-color: white;
   text-align:right;
   font-weight:bold;
   }
   
    table.gridtable td.second {
  text-align:left;
  padding-left: 20px;
  font-weight:normal;
 }
   table.gridtable th.left-rounded-corner{
   -moz-border-radius-topleft: 10px;
   -webkit-border-top-left-radius: 10px;
   border: 0px solid;
   }
   table.gridtable th.right-rounded-corner{
   -moz-border-radius-topright: 10px;
   -webkit-border-top-right-radius: 10px;
   border: 0px solid;
   }
   table.gridtable th.top{
   -moz-border-radius-topleft: 10px;
   -webkit-border-top-left-radius: 10px;
   -moz-border-radius-topright: 10px;
   -webkit-border-top-right-radius: 10px;
   border: 0px solid;
   background-color: #096bff;
   text-align:center;
   color: white;
   }
   table.gridtable th.bottom{
   -moz-border-radius-bottomleft: 10px;
   -webkit-border-bottom-left-radius: 10px;
   -moz-border-radius-bottomright: 10px;
   -webkit-border-bottom-right-radius: 10px;
   border: 0px solid;
   background-color: #CFCFCF;
   }
   tr:hover td { 
   background-color:#F7F7F7;
   }
&lt;/style&gt;
&lt;!-- Table goes in the document BODY --&gt;
&lt;br /&gt;
&lt;table align="center" class="gridtable"&gt;
   &lt;colgroup&gt;
      &lt;col width="150"&gt;&lt;/col&gt;
      
      &lt;col width="250"&gt;&lt;/col&gt;
      
   &lt;/colgroup&gt;
   &lt;tbody&gt;
&lt;tr&gt;
         &lt;th class="top" colspan="2"&gt;Float in a nutshell&lt;/th&gt;
      &lt;/tr&gt;
&lt;tr&gt;
         &lt;td&gt;Description&lt;/td&gt;
         &lt;td class="second"&gt;Used to store decimal values. They can be negative, zero and positive.&lt;/td&gt;
      &lt;/tr&gt;
&lt;tr&gt;
         &lt;td&gt;Examples&lt;/td&gt;
         &lt;td class="second"&gt;-273.987, 76.0f, 0.00, 180.45, 3.1423&lt;/td&gt;
      &lt;/tr&gt;
&lt;tr&gt;
         &lt;td&gt;Size&lt;/td&gt;
         &lt;td class="second"&gt;4 Bytes (may change based on system)&lt;/td&gt;
      &lt;/tr&gt;
&lt;tr&gt;
         &lt;td&gt;Range&lt;/td&gt;
         &lt;td class="second"&gt;-3.4e&lt;sup&gt;38&lt;/sup&gt; to +3.4e&lt;sup&gt;38&lt;/sup&gt;&lt;/td&gt;
      &lt;/tr&gt;
&lt;tr&gt;
         &lt;td&gt;Syntax&lt;/td&gt;
         &lt;td class="second"&gt;float variable ( = value) [, var1 = val1, ...] ; &lt;/td&gt;
      &lt;/tr&gt;
&lt;tr&gt;
         &lt;td&gt;Format Specifier&lt;/td&gt;
         &lt;td class="second"&gt;%f&lt;/td&gt;
      &lt;/tr&gt;
&lt;tr&gt;
         &lt;th class="bottom" colspan="2"&gt;&lt;/th&gt;
      &lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2013/10/float-data-type.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiLgZ8Knkj3KWyYLmjgXd7iJDez3ILzL4zig7YEk3WN7K4997TsqdDY7McQaMtmiypwRL5BZ4FxoAKTrf3sPLcEvyr8Lnkstt12qUJ7e4Wqw5IcgcgIJ0x1f4wUdSofAZocWYzhYUpKeo/s72-c/float+LOGO.jpg" width="72"/><thr:total>0</thr:total><enclosure length="56224" type="application/pdf" url="http://meseec.ce.rit.edu/eecc250-winter99/250-1-27-2000.pdf"/><itunes:explicit/><itunes:subtitle>The float is the second most commonly used data type used in C and allows you to store decimal numbers. You can use float data types to store results of operations involving a division operation. Before we start with an example lets learn more about it. Why is float 4 Bytes long ? As you may remember int is only 2 Bytes long(for 16 bit CPU, 4 Bytes for 32 bit CPU). So what makes float so special to require twice the amount of space? In a decimal number, its important to know the position of the decimal point. Consider this example: 129 &amp;lt; 1290 &amp;nbsp;, but 1.29 = 1.29. Similarly 1.29 &amp;lt; 12.9. The placement of the decimal point decides the value of the number and this is done in the following manner. Lets consider 3.141592 as an example. This number can be written as 3141592 x 10-5. This value is separated as 3141592 and -5. 3141592 is called the exponent, -5 the mantissa.&amp;nbsp;The compiler then makes use of these values and encodes the float representation using the IEEE 754 standard. As we need to store the information of two integers to represent a single float it requires twice the amount of space. and hence 4 Bytes of memory. Lets continue with the example to know more about float. /* Author: Ryan Sequeira Title: Float data type formatting */ #include &amp;lt;stdio.h&amp;gt; int main() { float n = 22.0f, d = 7.0f; float pi = n/d; //print the value of pi printf("The value of Pi: %18f\n", pi); //print the first 2 decimals of pi printf("Pi with first 2 decimals: %5.2f\n", pi); //print the first 20 decimals of pi printf("Pi with first 20 decimals: %.20f\n", pi); /* float prints 6 decimal places by default and gives a accuracy upto 20 decimal places. */ //print the first 25 decimals of pi printf("Pi with first 25 decimals: %.25f\n", pi); return 0; } Lets &amp;nbsp;understand how formatting works with float. float output for %5.2f We use %5.2f to print the above result. In this example 5 represents the number of places to reserve for the decimal and .2 represents the number of decimal digits to output. The number before the decimal point ( in %5.2f ) represents minimum number of blocks to reserve for the value, and the number after the decimal decides the number of places to round off the decimal. You can try this with integers too. But since there isn't a decimal here you can only use an integer value between % and d. Example &amp;nbsp;printf("%5d",100); will reserve 5 blocks for the value 100. You can use this formatting option to right align your results. Now that we have learnt a lot about float lets write a small program that converts temperature in Fahrenheit to Celsius and Kelvin. /* Author: Ryan Sequeira Title: Program to convert temperature in Fahrenheit to Celsius and Kelvin */ #include &amp;lt;stdio.h&amp;gt; int main() { //declaring variables to store temperatures float far = 0.0f; float cel = 0.0f; float kel = 0.0f; printf("Enter the temperature (in Fahrenheits): "); scanf("%f",&amp;amp;far); //formulas to convert Fahrenheit to Celsius cel = (far - 32) * (5.0f/9.0f); //formula to convert Fahrenheit to Kelvin kel = (far + 459.67f) * (5.0f/9.0f); printf("%.2f Fahrenheits equals \n %7.2f Celsius and \n %7.2f Kelvin\n", far, cel, kel); return 0; } table.gridtable { font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif; font-size: 13px; text-align: left; color:#333333; border-width: 0px; border-color: #FFFFFF; border-collapse: collapse; cellspacing: 50px; } table.gridtable th { padding: 8px; border-style: solid; border-width: 0px 1px 0px 1px; border-color: #E6E6E6; background-color: #FFCC00 ; } table.gridtable td { border-width: 1px; padding: 8px; border-style: solid; border-color: #CFCFCF; background-color: white; text-align:right; font-weight:bold; } table.gridtable td.second { text-align:left; padding-left: 20px; font-weight:normal; } table.gridtable th.left-rounded-corner{ -moz-border-radius-topleft: 10px; -webkit-border-top-left-radius: 10px; border: 0px solid; } table.gridtable th.right-rounded-corner{ -moz-border-radius-topright: 10px; -webkit-border-top-right-radius: 10px; border: 0px solid; } table.gridtable th.top{ -moz-border-radius-topleft: 10px; -webkit-border-top-left-radius: 10px; -moz-border-radius-topright: 10px; -webkit-border-top-right-radius: 10px; border: 0px solid; background-color: #096bff; text-align:center; color: white; } table.gridtable th.bottom{ -moz-border-radius-bottomleft: 10px; -webkit-border-bottom-left-radius: 10px; -moz-border-radius-bottomright: 10px; -webkit-border-bottom-right-radius: 10px; border: 0px solid; background-color: #CFCFCF; } tr:hover td { background-color:#F7F7F7; } Float in a nutshell Description Used to store decimal values. They can be negative, zero and positive. Examples -273.987, 76.0f, 0.00, 180.45, 3.1423 Size 4 Bytes (may change based on system) Range -3.4e38 to +3.4e38 Syntax float variable ( = value) [, var1 = val1, ...] ; Format Specifier %f</itunes:subtitle><itunes:author>noreply@blogger.com (Anonymous)</itunes:author><itunes:summary>The float is the second most commonly used data type used in C and allows you to store decimal numbers. You can use float data types to store results of operations involving a division operation. Before we start with an example lets learn more about it. Why is float 4 Bytes long ? As you may remember int is only 2 Bytes long(for 16 bit CPU, 4 Bytes for 32 bit CPU). So what makes float so special to require twice the amount of space? In a decimal number, its important to know the position of the decimal point. Consider this example: 129 &amp;lt; 1290 &amp;nbsp;, but 1.29 = 1.29. Similarly 1.29 &amp;lt; 12.9. The placement of the decimal point decides the value of the number and this is done in the following manner. Lets consider 3.141592 as an example. This number can be written as 3141592 x 10-5. This value is separated as 3141592 and -5. 3141592 is called the exponent, -5 the mantissa.&amp;nbsp;The compiler then makes use of these values and encodes the float representation using the IEEE 754 standard. As we need to store the information of two integers to represent a single float it requires twice the amount of space. and hence 4 Bytes of memory. Lets continue with the example to know more about float. /* Author: Ryan Sequeira Title: Float data type formatting */ #include &amp;lt;stdio.h&amp;gt; int main() { float n = 22.0f, d = 7.0f; float pi = n/d; //print the value of pi printf("The value of Pi: %18f\n", pi); //print the first 2 decimals of pi printf("Pi with first 2 decimals: %5.2f\n", pi); //print the first 20 decimals of pi printf("Pi with first 20 decimals: %.20f\n", pi); /* float prints 6 decimal places by default and gives a accuracy upto 20 decimal places. */ //print the first 25 decimals of pi printf("Pi with first 25 decimals: %.25f\n", pi); return 0; } Lets &amp;nbsp;understand how formatting works with float. float output for %5.2f We use %5.2f to print the above result. In this example 5 represents the number of places to reserve for the decimal and .2 represents the number of decimal digits to output. The number before the decimal point ( in %5.2f ) represents minimum number of blocks to reserve for the value, and the number after the decimal decides the number of places to round off the decimal. You can try this with integers too. But since there isn't a decimal here you can only use an integer value between % and d. Example &amp;nbsp;printf("%5d",100); will reserve 5 blocks for the value 100. You can use this formatting option to right align your results. Now that we have learnt a lot about float lets write a small program that converts temperature in Fahrenheit to Celsius and Kelvin. /* Author: Ryan Sequeira Title: Program to convert temperature in Fahrenheit to Celsius and Kelvin */ #include &amp;lt;stdio.h&amp;gt; int main() { //declaring variables to store temperatures float far = 0.0f; float cel = 0.0f; float kel = 0.0f; printf("Enter the temperature (in Fahrenheits): "); scanf("%f",&amp;amp;far); //formulas to convert Fahrenheit to Celsius cel = (far - 32) * (5.0f/9.0f); //formula to convert Fahrenheit to Kelvin kel = (far + 459.67f) * (5.0f/9.0f); printf("%.2f Fahrenheits equals \n %7.2f Celsius and \n %7.2f Kelvin\n", far, cel, kel); return 0; } table.gridtable { font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif; font-size: 13px; text-align: left; color:#333333; border-width: 0px; border-color: #FFFFFF; border-collapse: collapse; cellspacing: 50px; } table.gridtable th { padding: 8px; border-style: solid; border-width: 0px 1px 0px 1px; border-color: #E6E6E6; background-color: #FFCC00 ; } table.gridtable td { border-width: 1px; padding: 8px; border-style: solid; border-color: #CFCFCF; background-color: white; text-align:right; font-weight:bold; } table.gridtable td.second { text-align:left; padding-left: 20px; font-weight:normal; } table.gridtable th.left-rounded-corner{ -moz-border-radius-topleft: 10px; -webkit-border-top-left-radius: 10px; border: 0px solid; } table.gridtable th.right-rounded-corner{ -moz-border-radius-topright: 10px; -webkit-border-top-right-radius: 10px; border: 0px solid; } table.gridtable th.top{ -moz-border-radius-topleft: 10px; -webkit-border-top-left-radius: 10px; -moz-border-radius-topright: 10px; -webkit-border-top-right-radius: 10px; border: 0px solid; background-color: #096bff; text-align:center; color: white; } table.gridtable th.bottom{ -moz-border-radius-bottomleft: 10px; -webkit-border-bottom-left-radius: 10px; -moz-border-radius-bottomright: 10px; -webkit-border-bottom-right-radius: 10px; border: 0px solid; background-color: #CFCFCF; } tr:hover td { background-color:#F7F7F7; } Float in a nutshell Description Used to store decimal values. They can be negative, zero and positive. Examples -273.987, 76.0f, 0.00, 180.45, 3.1423 Size 4 Bytes (may change based on system) Range -3.4e38 to +3.4e38 Syntax float variable ( = value) [, var1 = val1, ...] ; Format Specifier %f</itunes:summary><itunes:keywords>Data Types, float</itunes:keywords></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-7332714832715233086</guid><pubDate>Sun, 06 Oct 2013 05:38:00 +0000</pubDate><atom:updated>2013-10-09T18:29:19.312+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Data Types</category><category domain="http://www.blogger.com/atom/ns#">int</category><title>Int Data Type</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0fKfEJPHy3H9pRVY4ZT1u1eRAiKXKrK6iIEBjGBwbHxO_yWZ4dd8c_QiQqGr4M_Y_9fjSGd0tT-8QKFyYQtcA7pea3uzq9RZ4pBm8LfthNKS95TqHbnzLxTemQP-N7NdJ4G51GsHC6QE/s1600/int+LOGO.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img alt="Int Data Type" border="0" height="212" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0fKfEJPHy3H9pRVY4ZT1u1eRAiKXKrK6iIEBjGBwbHxO_yWZ4dd8c_QiQqGr4M_Y_9fjSGd0tT-8QKFyYQtcA7pea3uzq9RZ4pBm8LfthNKS95TqHbnzLxTemQP-N7NdJ4G51GsHC6QE/s640/int+LOGO.jpg" title="Int Data Type" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Int Data Type is one of the most commonly used data types and used to store integer values. They can be negative, zero or positive.&lt;br /&gt;
For example: 2, 56, -8663 etc.&lt;br /&gt;
&lt;br /&gt;
Lets look at an example on how integers can be used.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt; 
/*  
 Author : Ryan Sequeira  
 Date : 22nd September 2012  
 Title : Calculate the age difference between two people
*/ 

#include&amp;lt;stdio.h&amp;gt;

int main(){
    //declaring 2 variables and initializing it with 0 
 int a = 0, b = 0;
 
 //prompting to enter age of first person and storing it in a
 printf("Enter age of first person: ");
 scanf("%d", &amp;amp;a);
 
 //prompting to enter age of second person and storing it in b
 printf("Enter age of second person: ");
 scanf("%d", &amp;amp;b);
 
 //printing the age difference
 printf("The age difference is: %d", abs(a-b));
 
 return 0;
}
&lt;/pre&gt;
&lt;br /&gt;
In this simple example you can see how variables are declared, initialized, re initialized with users value and finally used to calculate new results.&lt;br /&gt;
&lt;br /&gt;
Here we have initialized the variables with 0. It is always a good practice to initialize variables with appropriate values. For example if a program will use the variables to add or subtract, 0 is the value to be used and for multiplication and division operations you can use 1.&lt;br /&gt;
&lt;br /&gt;
We have used the abs function in this example. The abs function is used to calculate the absolute difference between 2 values i.e it returns only the difference and not the positive or negative sign.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;!-- CSS goes in the document HEAD or added to your external stylesheet --&gt;
&lt;style type="text/css"&gt;
   table.gridtable {
   font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
   font-size: 13px;
   text-align: left;
   color:#333333;
   border-width: 0px;
   border-color: #FFFFFF;
   border-collapse: collapse;
   cellspacing: 50px;
   }
   table.gridtable th {
   padding: 8px;
   border-style: solid;
   border-width: 0px 1px 0px 1px;
   border-color: #E6E6E6;
   background-color: #FFCC00 ;
   }
   table.gridtable td {
   border-width: 1px;
   padding: 8px;
   border-style: solid;
   border-color: #CFCFCF;
   background-color: white;
   text-align:right;
   font-weight:bold;
   }
   
    table.gridtable td.second {
  text-align:left;
  padding-left: 20px;
  font-weight:normal;
 }
   table.gridtable th.left-rounded-corner{
   -moz-border-radius-topleft: 10px;
   -webkit-border-top-left-radius: 10px;
   border: 0px solid;
   }
   table.gridtable th.right-rounded-corner{
   -moz-border-radius-topright: 10px;
   -webkit-border-top-right-radius: 10px;
   border: 0px solid;
   }
   table.gridtable th.top{
   -moz-border-radius-topleft: 10px;
   -webkit-border-top-left-radius: 10px;
   -moz-border-radius-topright: 10px;
   -webkit-border-top-right-radius: 10px;
   border: 0px solid;
   background-color: #fa0041;
   text-align:center;
   color: white;
   }
   table.gridtable th.bottom{
   -moz-border-radius-bottomleft: 10px;
   -webkit-border-bottom-left-radius: 10px;
   -moz-border-radius-bottomright: 10px;
   -webkit-border-bottom-right-radius: 10px;
   border: 0px solid;
   background-color: #CFCFCF;
   }
   tr:hover td { 
   background-color:#F7F7F7;
   }
&lt;/style&gt;
&lt;!-- Table goes in the document BODY --&gt;
&lt;br /&gt;
&lt;table align="center" class="gridtable"&gt;
   &lt;colgroup&gt;
      &lt;col width="150"&gt;&lt;/col&gt;
      
      &lt;col width="250"&gt;&lt;/col&gt;
      
   &lt;/colgroup&gt;
   &lt;tbody&gt;
&lt;tr&gt;
         &lt;th class="top" colspan="2"&gt;Int in a nutshell&lt;/th&gt;
      &lt;/tr&gt;
&lt;tr&gt;
         &lt;td&gt;Description&lt;/td&gt;
         &lt;td class="second"&gt;Used to store integer values. They can be negative, zero and positive.&lt;/td&gt;
      &lt;/tr&gt;
&lt;tr&gt;
         &lt;td&gt;Examples&lt;/td&gt;
         &lt;td class="second"&gt;-45, 38, 0, 1445, -9753&lt;/td&gt;
      &lt;/tr&gt;
&lt;tr&gt;
         &lt;td&gt;Size&lt;/td&gt;
         &lt;td class="second"&gt;4 Bytes (may change based on system)&lt;/td&gt;
      &lt;/tr&gt;
&lt;tr&gt;
         &lt;td&gt;Range&lt;/td&gt;
         &lt;td class="second"&gt;-32768 to 32767&lt;/td&gt;
      &lt;/tr&gt;
&lt;tr&gt;
         &lt;td&gt;Syntax&lt;/td&gt;
         &lt;td class="second"&gt;int variable ( = value) [, var1 = val1, ...] ; &lt;/td&gt;
      &lt;/tr&gt;
&lt;tr&gt;
         &lt;td&gt;Format Specifier&lt;/td&gt;
         &lt;td class="second"&gt;%d&lt;/td&gt;
      &lt;/tr&gt;
&lt;tr&gt;
         &lt;th class="bottom" colspan="2"&gt;&lt;/th&gt;
      &lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2013/10/int-data-type.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0fKfEJPHy3H9pRVY4ZT1u1eRAiKXKrK6iIEBjGBwbHxO_yWZ4dd8c_QiQqGr4M_Y_9fjSGd0tT-8QKFyYQtcA7pea3uzq9RZ4pBm8LfthNKS95TqHbnzLxTemQP-N7NdJ4G51GsHC6QE/s72-c/int+LOGO.jpg" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-7929808727006673834</guid><pubDate>Sun, 06 Oct 2013 05:36:00 +0000</pubDate><atom:updated>2013-10-06T15:07:54.957+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Data Types</category><category domain="http://www.blogger.com/atom/ns#">variables</category><title>Data Types and Variables in C</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXkqkCPMNGzgw_JH-x0guaDW_UOrWMaraJeRiBsku3eToh1cUQgThwK4Fc4oI_EwMZPUoZIF5yh830-cCUl-3k9HR45iX0bgnWDSM5Hg_3DbZpRCPOTsLuDxdhQt7KfpY7HLaU4-kGtkE/s1600/kids.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img alt="Data Types in C" border="0" height="204" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXkqkCPMNGzgw_JH-x0guaDW_UOrWMaraJeRiBsku3eToh1cUQgThwK4Fc4oI_EwMZPUoZIF5yh830-cCUl-3k9HR45iX0bgnWDSM5Hg_3DbZpRCPOTsLuDxdhQt7KfpY7HLaU4-kGtkE/s640/kids.jpg" title="Data Types in C" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that you know how to &lt;a href="http://mycodedotc.blogspot.in/2013/09/taking-inputs-from-user.html" target="_blank"&gt;&lt;span id="goog_2028437103"&gt;&lt;/span&gt;take inputs from users&lt;span id="goog_2028437104"&gt;&lt;/span&gt;&lt;/a&gt;, lets understand what Data-Types are, as they determine the kind of input and output out program can handle.&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;
What are Data Types ?&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
A &lt;b&gt;data type&lt;/b&gt; or simply &lt;b&gt;type&lt;/b&gt; is a classification, identifying one of various types of data, such as real-valued, integer or character.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;It&amp;nbsp;&lt;b&gt;determines the possible values&lt;/b&gt; for that type;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;The &lt;b&gt;operations that can be done&lt;/b&gt; on values of that type;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;The &lt;b&gt;meaning of the data&lt;/b&gt;;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;And the &lt;b&gt;way values of that type can be stored&lt;/b&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The basic data types in c are:&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Int&lt;/li&gt;
&lt;li&gt;Float&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Char&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
A complete list of data types is given below&lt;br /&gt;
&lt;br /&gt;
&lt;!-- CSS goes in the document HEAD or added to your external stylesheet --&gt;
&lt;style type="text/css"&gt;
table.gridtable {
 font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
 font-size: 13px;
 text-align: left;
 color:#333333;
 border-width: 0px;
 border-color: #FFFFFF;
 border-collapse: collapse;
 cellspacing: 50px;
}
table.gridtable th {
 padding: 8px;
 border-style: solid;
 border-width: 0px 1px 0px 1px;
 border-color: #ffffff;
 background-color: #FFCC00 ;

}
table.gridtable td {
 border-width: 1px;
 padding: 8px;
 border-style: solid;
 border-color: #FFFFFF;
 background-color: #FFE066;
}


table.gridtable th.left-rounded-corner{
  -moz-border-radius-topleft: 10px;
    -webkit-border-top-left-radius: 10px;
    border: 0px solid;
}

table.gridtable th.right-rounded-corner{
  -moz-border-radius-topright: 10px;
    -webkit-border-top-right-radius: 10px;
    border: 0px solid;
}


table.gridtable td.right-rounded-corner{
  -moz-border-radius-bottomright: 10px;
    -webkit-border-bottom-right-radius: 10px;
    border: 0px solid;
}


table.gridtable th.bottom{
  -moz-border-radius-bottomleft: 10px;
    -webkit-border-bottom-left-radius: 10px;
  -moz-border-radius-bottomright: 10px;
    -webkit-border-bottom-right-radius: 10px;
    border: 0px solid;
 background-color: #FFE066;
}

tr:hover td { 
 background-color:#FFEB99;
}

&lt;/style&gt;

&lt;script&gt;
 function DoNav(theUrl)
  {
  window.open(theUrl);
  }
 &lt;/script&gt;


&lt;!-- Table goes in the document BODY --&gt;
&lt;br /&gt;
&lt;table align="center" class="gridtable"&gt; 
&lt;colgroup&gt;&lt;col width="150"&gt;&lt;/col&gt;
&lt;col width="200"&gt;&lt;/col&gt;
&lt;col width="200"&gt;&lt;/col&gt;

&lt;/colgroup&gt;&lt;tbody&gt;
&lt;tr&gt;
 &lt;th class="left-rounded-corner"&gt;Keyword&lt;/th&gt;&lt;th&gt;Variable Type&lt;/th&gt;&lt;th class="right-rounded-corner"&gt;Range&lt;/th&gt;
&lt;/tr&gt;
&lt;tr onclick="DoNav('http://www.yahoo.com/')"&gt;
 &lt;td&gt;char&lt;/td&gt;&lt;td&gt;Character (or string)&lt;/td&gt;&lt;td&gt;-128 to 127&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;int&lt;/td&gt;&lt;td&gt;Integer&lt;/td&gt;&lt;td&gt;-32,768 to 32,767&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;short&lt;br /&gt;
short int&lt;/td&gt;&lt;td&gt;Short integer&lt;/td&gt;&lt;td&gt;-32,768 to 32,767&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;long&lt;/td&gt;&lt;td&gt;Long integer&lt;/td&gt;&lt;td&gt;-2,147,483,648&lt;br /&gt;
to 2,147,483,647&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;unsigned char&lt;/td&gt;&lt;td&gt;Unsigned character&lt;/td&gt;&lt;td&gt;0 to 255&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;unsigned int&lt;/td&gt;&lt;td&gt;Unsigned integer&lt;/td&gt;&lt;td&gt;0 to 65,535&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;unsigned short&lt;/td&gt;&lt;td&gt;Unsigned short integer&lt;/td&gt;&lt;td&gt;0 to 65,535&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;unsigned long&lt;/td&gt;&lt;td&gt;Unsigned long integer&lt;/td&gt;&lt;td&gt;0 to 4,294,967,295&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;float&lt;/td&gt;&lt;td&gt;Single-precision&lt;br /&gt;
floating point&lt;br /&gt;
(accurate to 7 digits)&lt;/td&gt;&lt;td&gt;±3.4 × 10&lt;sup&gt;-38&lt;/sup&gt; to&lt;br /&gt;
±3.4 × 10&lt;sup&gt;38&lt;/sup&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;double&lt;/td&gt;&lt;td&gt;Double-precision&lt;br /&gt;
floating point&lt;br /&gt;
(accurate to 15 digits)&lt;/td&gt;&lt;td&gt;±1.7 × 10&lt;sup&gt;-308&lt;/sup&gt; to&lt;br /&gt;
±1.7 × 10&lt;sup&gt;308&lt;/sup&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;th class="bottom" colspan="3"&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;
&lt;/h3&gt;
&lt;h3 style="text-align: left;"&gt;
What are Variables and how are they related to data types?&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Variables are used to store values temporarily in your program. The life span of a variable can be at most equal to the time the program executes.&lt;br /&gt;
As the compiler needs to know what type of data is to be stored (different data types are stored differently as different operations can be performed based on the data type) we assign a data type to each variable.&lt;br /&gt;
The syntax to create variables is variable name followed by one or more variables, separated by comma. You can also initialize each variable in the same statement. Also as variables are declared from left to right you can use the value of the variable on the left to assign current variables' value.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example:&lt;/b&gt;&amp;nbsp; int a = 9, b = 2*a;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this way a=9 and b=18&lt;br /&gt;
&lt;br /&gt;
Lets understand each data type in detail.&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Understanding integer data type.&lt;/li&gt;
&lt;li&gt;Understanding float data type.&lt;/li&gt;
&lt;li&gt;Understanding character data type.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2013/10/data-types-and-variables-in-c.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXkqkCPMNGzgw_JH-x0guaDW_UOrWMaraJeRiBsku3eToh1cUQgThwK4Fc4oI_EwMZPUoZIF5yh830-cCUl-3k9HR45iX0bgnWDSM5Hg_3DbZpRCPOTsLuDxdhQt7KfpY7HLaU4-kGtkE/s72-c/kids.jpg" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-5571394221360459673</guid><pubDate>Tue, 03 Sep 2013 14:50:00 +0000</pubDate><atom:updated>2013-10-06T15:08:15.667+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Basics</category><title>Taking inputs from User</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVCf0CfbGdMcybotKkJkfAOuMgo0wFIe4dSliaxuDs4tHQWyYPcweetvlzycRHx37260SUfF80JTntBwQzwGhIRMexYy5Z1J94_ABErBtpJi7d1xNBFKizcIWCmxP75N93ty2DKwuZibA/s1600/conveyor%60.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img alt="Taking Inputs from Users" border="0" height="290" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVCf0CfbGdMcybotKkJkfAOuMgo0wFIe4dSliaxuDs4tHQWyYPcweetvlzycRHx37260SUfF80JTntBwQzwGhIRMexYy5Z1J94_ABErBtpJi7d1xNBFKizcIWCmxP75N93ty2DKwuZibA/s640/conveyor%60.jpg" title="Taking Inputs from Users" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
This will be the first program where you will learn to take an input from user. And to do so we will write a program that welcomes you. So lets begin.&lt;br /&gt;
&lt;br /&gt;
Copy the code below and execute. You will be prompted to "Enter your name", and on doing so it will print a message with your name. Remember to press the Enter key after the input.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;/*
    Author: Ryan Sequeira
    Title:  A program that welcomes you
*/

#include &amp;lt;stdio.h&amp;gt;

int main()
{
    char name[20];
    
    printf("Enter your name: ");    //prompt the user to enter his name
    scanf("%s",&amp;amp;name);    //scan users input
    
    printf("Welcome %s !!!",name);    //print the welcome message
    
    return 0;
}

&lt;/pre&gt;
&lt;br /&gt;
Lets understand how the code works. Since the program needs to remember your name, we need to create a variable of type string (a string is a sequence of characters, we will learn it in detail later ).&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;    char name[20];
&lt;/pre&gt;
&lt;br /&gt;
The line above creates a string variable that can remember 19 characters. **(one character is reserved for a special symbol to detect string termination).&lt;br /&gt;
&lt;br /&gt;
The next two important lines of code are the scanf statement and printf with a variable.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;    scanf("%s",&amp;amp;name);    //scan users input
    printf("Welcome %s !!!", name);    //print the welcome message
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;scanf&lt;/b&gt; is used for receiving formatted Input and&lt;br /&gt;
&lt;b&gt;printf&lt;/b&gt; is used for displaying formatted Output.&lt;br /&gt;
&lt;br /&gt;
We can break the scanf and printf into two parts.&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Control String&lt;/li&gt;
&lt;li&gt;Variables&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 style="text-align: left;"&gt;
&lt;/h4&gt;
&lt;h4 style="text-align: left;"&gt;
Control String&lt;/h4&gt;
&lt;div&gt;
The control string is used to describe the formatted structure of the input or the output. If we directly wrote the variable names inside the formatted string the compiler wouldn't be able to differentiate it from the other characters in the string. Hence we make use of place holders for variables and list the variables outside so that the compiler can substitute the value of the variable in that place(in case of printf).&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style="text-align: left;"&gt;
Variables&lt;/h4&gt;
&lt;/div&gt;
&lt;div&gt;
As we use place holders, the variables outside must match the total number of places holders used in the control string. Also the type of the place holders must match the variables. For example consider the following statement:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;    int age=0;
    float percentage=0.0;
    char name[19];
    
    scanf("%s %d %f",&amp;amp;name, &amp;amp;age, &amp;amp;percentage);    //scan users name, age and percentage
    printf("Welcome %s !!!", name);    //print the welcome message
    printf("\nYour are %d years old and you scored %f this year", age, percentage);    
&lt;/pre&gt;
&lt;br /&gt;
As you can see, in the scanf statement we scan three inputs viz name, age and percentage. Here the %s matches the name, %d (placeholder for integer) the age and %f (placeholder for float/decimal) the percentage.&lt;br /&gt;
Similarly in the second printf statement %d is followed by %f and hence the age is ahead of percentage in the variable list.&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style="text-align: left;"&gt;
Format Specifiers&lt;/h4&gt;
&lt;br /&gt;
&lt;!-- CSS goes in the document HEAD or added to your external stylesheet --&gt;
&lt;style type="text/css"&gt;
table.gridtable {
 font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
 font-size: 13px;
 text-align: left;
 color:#333333;
 border-width: 0px;
 border-color: #FFFFFF;
 border-collapse: collapse;
 cellspacing: 50px;
}
table.gridtable th {
 padding: 8px;
 border-style: solid;
 border-width: 0px 1px 0px 1px;
 border-color: #ffffff;
 background-color: #B3B3B3;

}
table.gridtable td {
 border-width: 1px;
 padding: 8px;
 border-style: solid;
 border-color: #FFFFFF;
 background-color: #DFDFDF;
}


table.gridtable th.left-rounded-corner{
  -moz-border-radius-topleft: 10px;
    -webkit-border-top-left-radius: 10px;
    border: 0px solid;
}

table.gridtable th.right-rounded-corner{
  -moz-border-radius-topright: 10px;
    -webkit-border-top-right-radius: 10px;
    border: 0px solid;
}


table.gridtable td.right-rounded-corner{
  -moz-border-radius-bottomright: 10px;
    -webkit-border-bottom-right-radius: 10px;
    border: 0px solid;
}


table.gridtable th.bottom{
  -moz-border-radius-bottomleft: 10px;
    -webkit-border-bottom-left-radius: 10px;
  -moz-border-radius-bottomright: 10px;
    -webkit-border-bottom-right-radius: 10px;
    border: 0px solid;
 background-color: #DFDFDF;
}

tr:hover td { 
 background-color: #EAEAEA;
}

&lt;/style&gt;
&lt;!-- Table goes in the document BODY --&gt;
&lt;br /&gt;
&lt;table align="center" class="gridtable"&gt;
&lt;tbody&gt;
&lt;tr&gt;
 &lt;th class="left-rounded-corner"&gt;Placeholder&lt;/th&gt;&lt;th&gt;Variable Type&lt;/th&gt;&lt;th class="right-rounded-corner"&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;%c&lt;/td&gt;&lt;td&gt;char&lt;/td&gt;&lt;td&gt;single character&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;%d (%i)&lt;/td&gt;&lt;td&gt;int&lt;/td&gt;&lt;td&gt;signed integer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;%e (%E)&lt;/td&gt;&lt;td&gt;float or double&lt;/td&gt;&lt;td&gt;exponential format&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;%f&lt;/td&gt;&lt;td&gt;float or double&lt;/td&gt;&lt;td&gt;signed decimal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;%g (%G)&lt;/td&gt;&lt;td&gt;float or double&lt;/td&gt;&lt;td&gt;use %f or %e as required&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;%o&lt;/td&gt;&lt;td&gt;int&lt;/td&gt;&lt;td&gt;octal value&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;%p&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;pointer address stored in pointer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;%s&lt;/td&gt;&lt;td&gt;array of char &lt;/td&gt;&lt;td&gt;sequence of characters&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;%u&lt;/td&gt;&lt;td&gt;int&lt;/td&gt;&lt;td&gt;unsigned decimal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;%x (%X)&lt;/td&gt;&lt;td&gt;int&lt;/td&gt;&lt;td&gt;unsigned hex value&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;th class="bottom" colspan="3"&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Now that you know how to take input and display it try do it your self exercises.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;
Do it your self&amp;nbsp;&lt;/h3&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Implement the code that scans name, age and percentage.&lt;/li&gt;
&lt;li&gt;Write a program that takes name and percentage of 3 users and display the names and percentage side by side&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Example&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Name &amp;nbsp; Percentage&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Joel &amp;nbsp; &amp;nbsp; &amp;nbsp;33.5%&lt;/li&gt;
&lt;li&gt;Marco &amp;nbsp;56.5%&lt;/li&gt;
&lt;li&gt;Sam &amp;nbsp; &amp;nbsp; 90.6%&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;/ol&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2013/09/taking-inputs-from-user.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVCf0CfbGdMcybotKkJkfAOuMgo0wFIe4dSliaxuDs4tHQWyYPcweetvlzycRHx37260SUfF80JTntBwQzwGhIRMexYy5Z1J94_ABErBtpJi7d1xNBFKizcIWCmxP75N93ty2DKwuZibA/s72-c/conveyor%60.jpg" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-6392248002427710869</guid><pubDate>Sat, 31 Aug 2013 05:04:00 +0000</pubDate><atom:updated>2013-10-06T15:08:33.540+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Basics</category><title>Deconstructing a C Program</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;style&gt; span { word-break: keep-all;}&lt;/style&gt;

&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp-X7K7rCHlje8sak9EdPv6gu-cOxjcOTZuTFrRP3YU_E0Va1lRAzwZiPKNOagqsaH9pIWszs2jgwktpAkXiYxo2oJbi3GQ3vrWF22UNufxKk7ryJFLDndzMThvFEnQq_Omxdyo7US1W4/s1600/girl-who-had-gastric-bypass-in-mexico-surgery-no-attending.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img alt="Deconstructing a C Program" border="0" height="360" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp-X7K7rCHlje8sak9EdPv6gu-cOxjcOTZuTFrRP3YU_E0Va1lRAzwZiPKNOagqsaH9pIWszs2jgwktpAkXiYxo2oJbi3GQ3vrWF22UNufxKk7ryJFLDndzMThvFEnQq_Omxdyo7US1W4/s640/girl-who-had-gastric-bypass-in-mexico-surgery-no-attending.png" title="Deconstructing a C Program" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
We now know how to &lt;a href="http://mycodedotc.blogspot.in/2013/08/enter-dragon-running-out-first-program.html" target="_blank"&gt;run a C program in linux&lt;/a&gt;. So its time to understand the inner workings of a program. For this purpose we will take a small program and dissect and understand it one part at a time. The whole program may look confusing but understanding each component in isolation will make things simple and clear.&lt;br /&gt;
&lt;br /&gt;
So lets take this example. A simple program that prints a line on the screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;/*  
  Title: code that prints a line.  
  Author: Roshan Tirkey  
*/  

#include&amp;lt;stdio.h&amp;gt;

int main(){  
    // no need for local variables  

    printf("This is my first program\n");  
    return 0;
 } 
&lt;/pre&gt;
&lt;br /&gt;
**Its important that you understand the basics correctly, hence if there is anything that you find confusing or needs to be explained in detail please comment below. Finally the intent of the blog is to make things simpler for you to understand, and anything that deviates us from doing that should be removed.&lt;br /&gt;
&lt;br /&gt;
The code above can be broken down into five parts, each of which you will be able to reuse in your programs. Each component is listed below and discussed in detail.&lt;br /&gt;
&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;The comments&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Single line comments&lt;/li&gt;
&lt;li&gt;Multi line comments&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;The&amp;nbsp;preprocessor statement&lt;/li&gt;
&lt;li&gt;The main function&lt;/li&gt;
&lt;li&gt;The printf statement&lt;/li&gt;
&lt;li&gt;The return statement&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style="text-align: left;"&gt;
The Comments&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Comments are never processed. As a matter of fact when the code is converted into binary code the comments and all the white-spaces are neglected, since the compiler only understands the commands.&lt;/div&gt;
&lt;div&gt;
The reason why one should include comments in his programs is that as the complexity of the program increases it becomes more and more difficult for other programmers to understand. Hence is a good practice to include comments, starting with your first program.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;
Single-line comments&lt;/h4&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9iaLKi_2Ii06N5_K_uDfnwu3uV-7ZtFTk3iFyrbmEKbHcfH0IoPsngwjjop5va13j5SpjJErBX9Glw1n71gzFO8nNBVEnFZyKGKDwFxph0oI_cgfT3tiwXohuh2b9wCBo-yHRMCyA_HU/s1600/scomment.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img alt="Single Line comments" border="0" height="14" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9iaLKi_2Ii06N5_K_uDfnwu3uV-7ZtFTk3iFyrbmEKbHcfH0IoPsngwjjop5va13j5SpjJErBX9Glw1n71gzFO8nNBVEnFZyKGKDwFxph0oI_cgfT3tiwXohuh2b9wCBo-yHRMCyA_HU/s640/scomment.jpg" title="Single Line comments" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div&gt;
A single line comment is used to comment out only one line of code. Anything written after two backslashes &lt;b&gt; "//" &lt;/b&gt; will be considered a comment. Hence you can write a line of code followed by &lt;b&gt;//&lt;/b&gt; and explain it.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;b&gt;Example:&lt;/b&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;printf("Hello\n"); // prints Hello followed by new line
&lt;/pre&gt;
&lt;br /&gt;
You can also use comments to keep some line of code from executing. This technique comes handy when debugging your code, as you can comment out some part of the code and check if the error has disappeared. The example below will show how its done.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;//printf("Hello User\n");

printf("Welcome User\n");
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style="text-align: left;"&gt;
Multi-line comments&lt;/h4&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLpxnFTsjvGkLmaEAVFVJpKX56Pv9rLawOCSHz8Apkr1dKfzbDP0OnVWV3Dcbn6fsq9MQC2NabcQoPKNw5C2JYt0-tZhmkRzgihMm-HtIfcdgR1OOZ4ndfpIsFu57TGlUhFZ7PjXIqdI4/s1600/mcomment.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img alt="Multi Line comments" border="0" height="62" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLpxnFTsjvGkLmaEAVFVJpKX56Pv9rLawOCSHz8Apkr1dKfzbDP0OnVWV3Dcbn6fsq9MQC2NabcQoPKNw5C2JYt0-tZhmkRzgihMm-HtIfcdgR1OOZ4ndfpIsFu57TGlUhFZ7PjXIqdI4/s640/mcomment.jpg" title="Multi Line comments" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
You can make use of multi-line comments to add a description for your program, describing attributes like author, date of creation, title of the program along with a short description of what it does.&lt;/div&gt;
&lt;div&gt;
Alternately you can also used it to comment out a block of code. This way you can un-comment it whenever you want. This comes in handy while debugging. Let me demonstrate how its done with this example&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class="brush: cpp"&gt;#include&amp;lt;stdio.h&amp;gt;

int main(){  
/*
    printf("Welcome\n");  
    printf("Good Morning\n"); 
*/
    printf("Hello\n");  
    printf("Good Afternoon\n"); 

    return 0;
 } &lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style="text-align: left;"&gt;
The proprocessor statement&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFgGYHc_lRq45x31vXGOorbXuFHi1TmhWc0WCCNvT4cF3DrceXunrlCHJCSIa3CHaspCLosd8iKgFGYDdBHFsesI81WEf6w6-a8FLARWYlh5D8c4PqqQuula-vK9e-cK5LCXNxYOkVRIk/s1600/preprocessor.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img alt="Pre processor Statement" border="0" height="14" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFgGYHc_lRq45x31vXGOorbXuFHi1TmhWc0WCCNvT4cF3DrceXunrlCHJCSIa3CHaspCLosd8iKgFGYDdBHFsesI81WEf6w6-a8FLARWYlh5D8c4PqqQuula-vK9e-cK5LCXNxYOkVRIk/s640/preprocessor.jpg" title="Pre processor Statement" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The pre-processor statements allow us to make use of functions that are already implemented. The pre-processor statements are made of two parts&lt;/div&gt;
&lt;div&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;include - The include keyword&lt;/li&gt;
&lt;li&gt;stdio.h - The file where the functions are already implemented&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
When the compiler reads this statement, the file is fetched and the functions that we require are linked to our program. That way our program becomes independent of other files.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style="text-align: left;"&gt;
The main function&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqiZoCJN9LVL14mowvXbFmNUvrxIXjFQCmrQsl_2G8n89YR67rg56eWQgOYS9TZjBXSjmO_7nfmTKqbqLjatei_dArAwI4GCi8ywSIbsyS4PEsfGs3Gs-xUHo94dOBW58udMxkcg_CIro/s1600/main.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img alt="Main Function Structure" border="0" height="110" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqiZoCJN9LVL14mowvXbFmNUvrxIXjFQCmrQsl_2G8n89YR67rg56eWQgOYS9TZjBXSjmO_7nfmTKqbqLjatei_dArAwI4GCi8ywSIbsyS4PEsfGs3Gs-xUHo94dOBW58udMxkcg_CIro/s640/main.jpg" title="Main Function Structure" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The main program is the entry point for the execution of our program. Each line written within the main program block is executed sequentially. Hence a C program cannot run without a main program.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style="text-align: left;"&gt;
The printf statement&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFnz4QudIQ7ednS-WhbORr4IXK87qNR2GH-n7j6fCyAFxbNSvTOKWlyZlj2acRGXGrAACg-g2dg7NSRRjwvzcTDlh2Dersbbt26W5fbBph4Ud3EIyztadFQa6w9qB2EFLWXpUgVX893T4/s1600/print.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img alt="printf statement" border="0" height="14" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFnz4QudIQ7ednS-WhbORr4IXK87qNR2GH-n7j6fCyAFxbNSvTOKWlyZlj2acRGXGrAACg-g2dg7NSRRjwvzcTDlh2Dersbbt26W5fbBph4Ud3EIyztadFQa6w9qB2EFLWXpUgVX893T4/s640/print.jpg" title="printf statement" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The printf statement is the functionality we import from stdio.h. This function allows us to print a string(a message) on the terminal(stdout). Later as we learn data types we will use it to format text as well.&lt;/div&gt;
&lt;div&gt;
**The &lt;b&gt;"\n"&lt;/b&gt; is a placeholder for a new line.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style="text-align: left;"&gt;
The return statement&lt;/h3&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNuB9OyJdY5svyp38kdJUgmNnELFsXlId2FQZSo3nQnQvc69kAd1RkTD8WpjV4w8w5IkdE77R30b5nCojKfQdvLgRHI5uFD0pENVedIcWqHHt5ydvDHenJx9GdGV-XTEJVN2_QLTCjyL4/s1600/return.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img alt="return statement" border="0" height="110" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNuB9OyJdY5svyp38kdJUgmNnELFsXlId2FQZSo3nQnQvc69kAd1RkTD8WpjV4w8w5IkdE77R30b5nCojKfQdvLgRHI5uFD0pENVedIcWqHHt5ydvDHenJx9GdGV-XTEJVN2_QLTCjyL4/s640/return.jpg" title="return statement" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The return statement, as the name suggests returns a value. Since the main function has a return type of int, it is mandatory for us to return an integer value. A main function returning a value 0 is considered to have executed successfully. &lt;/div&gt;
&lt;div&gt;
**Note that anything written below the return statement, in that block, will not be executed since the execution of that function is stopped and the value returned.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style="text-align: left;"&gt;
*Indentation&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfDt514IEGscECcd0FkroHl_Ieur9JnnwvaQAf6ixKpbj2BlpGRQtMqrtPFeezghfyeSJrTiNEbLgpST4ongDdg9f7W2mYGwnyOk98mjjxrMOlvIjWwybjzOlTgiTN7w6Mqbs0FCMWtY4/s1600/indent.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img alt="Indentation in C" border="0" height="186" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfDt514IEGscECcd0FkroHl_Ieur9JnnwvaQAf6ixKpbj2BlpGRQtMqrtPFeezghfyeSJrTiNEbLgpST4ongDdg9f7W2mYGwnyOk98mjjxrMOlvIjWwybjzOlTgiTN7w6Mqbs0FCMWtY4/s640/indent.jpg" title="Indentation in C" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
As you can see the code we considered was easy to read, and one can easily figure out which lines of code belong within the main function. Making use of tabs allows us to describe the hierarchy withing the program. This process of formatting the program is called indentation. Incorporating indentation will not only make your code look beautiful but it will also convey more meaning and hence become easier to read.&lt;/div&gt;
&lt;div&gt;
**Indentation comes in handy when debugging the code.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style="margin: 0px; position: relative;"&gt;
&lt;b style="color: #333333; line-height: 12.727272033691406px; white-space: pre-wrap;"&gt;&lt;span style="font-family: Arial, Helvetica, sans-serif;"&gt;Do it yourself&lt;/span&gt;&lt;/b&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;div style="color: #333333; line-height: 12.727272033691406px; white-space: pre-wrap;"&gt;
&lt;/div&gt;
&lt;ol&gt;
&lt;li style="color: #333333; line-height: 12.727272033691406px; margin: 0px 0px 0.25em; padding: 0px; white-space: pre-wrap;"&gt;&lt;span style="color: black; line-height: normal; white-space: normal;"&gt;Try to print "Hello Everyone".&lt;/span&gt;&lt;/li&gt;
&lt;li style="margin: 0px 0px 0.25em; padding: 0px;"&gt;Place return 0; above printf and see what happens.&lt;/li&gt;
&lt;li style="margin: 0px 0px 0.25em; padding: 0px;"&gt;Comment the printf command ( type // before it ) and see how the programs works.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2013/08/deconstructing-program_31.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgp-X7K7rCHlje8sak9EdPv6gu-cOxjcOTZuTFrRP3YU_E0Va1lRAzwZiPKNOagqsaH9pIWszs2jgwktpAkXiYxo2oJbi3GQ3vrWF22UNufxKk7ryJFLDndzMThvFEnQq_Omxdyo7US1W4/s72-c/girl-who-had-gastric-bypass-in-mexico-surgery-no-attending.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-8057533631768217705</guid><pubDate>Sun, 25 Aug 2013 15:14:00 +0000</pubDate><atom:updated>2013-10-06T15:08:44.340+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Basics</category><title>Enter the Dragon - Running your first program</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shCore.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shBrushCpp.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;script type="text/javascript"&gt;
  SyntaxHighlighter.config.clipboardSwf = 'https://dl.dropbox.com/u/102425073/code/scripts/clipboard.swf';
  SyntaxHighlighter.all();
 &lt;/script&gt;
&lt;style&gt;
table.gridtable th {
 padding: 8px;
 background-color: #FFCC00 ;
}

table.gridtable th.rounded{


 -moz-border-radius: 10px;
  border-radius: 10px;
 background-color: #DFDFDF;
}

tr:hover th.click{ 
 background-color:#B3B3B3;
}
&lt;/style&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://spinoff.comicbookresources.com/wp-content/uploads/2013/06/enter-the-dragon2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="272" src="http://spinoff.comicbookresources.com/wp-content/uploads/2013/06/enter-the-dragon2.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Before we run our first program lets make sure you have&lt;b&gt; Linux installed on your PC&lt;/b&gt;.&lt;br /&gt;
If not the check our installation guide.&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;&lt;b&gt;&lt;a href="http://mycodedotc.blogspot.in/2013/08/installing-ubuntu-with-windows.html" target="_blank"&gt;Installing Ubuntu with Windows&lt;/a&gt;.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;a href="http://mycodedotc.blogspot.in/2013/08/install-ubuntu-on-virtual-machine.html" target="_blank"&gt;Installing Ubuntu on a Virtual Machine&lt;/a&gt;.&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
*If you install Linux on a Virtual Machine you won't have to restart your PC to switch between Windows and Linux&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Since you will be using Linux for the first time, I made sure there were a lot of screenshots to guide you.&lt;br /&gt;
&lt;br /&gt;
For first time you &amp;nbsp;run a C program on Linux (Ubuntu) you will have to:&lt;br /&gt;
&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Create a directory and the (program) file.&lt;/li&gt;
&lt;li&gt;Locate it on the Terminal.&lt;/li&gt;
&lt;li&gt;Run the C program on the Terminal.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 style="text-align: left;"&gt;
Create a directory and the (program) file.&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;
Step 1:&lt;/h4&gt;
&lt;div&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;b&gt;Open the Home directory&lt;/b&gt; using the file explorer.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOKZ8dFN41uA2ddIApZbNBLC0XwlCNHEa-etr7MudqDoLqLYQHaCy5KhvlX4oBhD9tEuMec6qLcGqsUUTnNiUBUOWZT4BXYMH0YWbcKASZ88MTkiYKN7-yT10g4_XKOlXnIneCadZMkfg/s1600/pic4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="266" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOKZ8dFN41uA2ddIApZbNBLC0XwlCNHEa-etr7MudqDoLqLYQHaCy5KhvlX4oBhD9tEuMec6qLcGqsUUTnNiUBUOWZT4BXYMH0YWbcKASZ88MTkiYKN7-yT10g4_XKOlXnIneCadZMkfg/s400/pic4.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;h4&gt;
Step 2:&lt;/h4&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;b&gt;Create a new directory&lt;/b&gt;, name it MyPrograms. To create a directory simply Right Click and select New Directory.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig0PXRz89MJ7FZHEdiCgOPsV8mfDDSUpFYnrGaDUibNn2NREKCwxVcvdyrwENQjOwd0jLXF9yttFlsEC9H2A3aVSHdyTo8zdfGKJBaN9_GLQJBbNmhlseCGtSlI1A9u1xwTZB3CxVK90c/s1600/pic5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="276" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEig0PXRz89MJ7FZHEdiCgOPsV8mfDDSUpFYnrGaDUibNn2NREKCwxVcvdyrwENQjOwd0jLXF9yttFlsEC9H2A3aVSHdyTo8zdfGKJBaN9_GLQJBbNmhlseCGtSlI1A9u1xwTZB3CxVK90c/s400/pic5.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4&gt;
Step 3:&lt;/h4&gt;
&lt;div class="" style="clear: both; text-align: left;"&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;&lt;b&gt;Create a new file&lt;/b&gt;(Empty Document) in &lt;b&gt;MyPrograms&lt;/b&gt; directory. To create a file, RightClick, followed by New Document and select Empty Document. Name it &lt;b&gt;FirstProgram.c&lt;/b&gt;&lt;/div&gt;
&lt;div class="" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEght0vHXo6rPN-SMRUv_BNtOIIT8fNk3erYrh_qd8GUD5bogo21W7dadzve_s3gSaMW50E7mWbC8SF1Blc_QPZrx0q9Y-C0yknbzvqVX8nOvNK4URVmypsMZlMVrdU61Mm4ryuttqzTq94/s1600/pic6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="276" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEght0vHXo6rPN-SMRUv_BNtOIIT8fNk3erYrh_qd8GUD5bogo21W7dadzve_s3gSaMW50E7mWbC8SF1Blc_QPZrx0q9Y-C0yknbzvqVX8nOvNK4URVmypsMZlMVrdU61Mm4ryuttqzTq94/s400/pic6.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="" style="clear: both; text-align: left;"&gt;
*Make sure you don't leave a blank space in the directory name or file name.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4&gt;
Step 4:&lt;/h4&gt;
&lt;div class="" style="clear: both; text-align: left;"&gt;
Now &lt;b&gt;open the file&lt;/b&gt; and &lt;b&gt;copy the code&lt;/b&gt; below.&lt;/div&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;#include&amp;lt;stdio.h&amp;gt;

int main(){
 printf("Congratulations,\nYou successfully ran this piece of code !!!\n");

 return 1;
}
&lt;/pre&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdam6xRZ44X33QA8_P9S6MjGQUJFMaV9a0TYvV4PCHlCPDqPeWMGzZtcIM6AC6dSAmzgm0qbThnM_Xhvg1V6Mfrdz9S5sy4N6TQY94z51cEU0-OXhCciEB2oC10VblZFfqFD9objDfYXg/s1600/pic7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="245" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdam6xRZ44X33QA8_P9S6MjGQUJFMaV9a0TYvV4PCHlCPDqPeWMGzZtcIM6AC6dSAmzgm0qbThnM_Xhvg1V6Mfrdz9S5sy4N6TQY94z51cEU0-OXhCciEB2oC10VblZFfqFD9objDfYXg/s400/pic7.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;span style="text-align: left;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="color: #cccccc; font-size: large;"&gt;&lt;b&gt;Congratulations, you created your first C program.&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="color: #cccccc; font-size: large;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="color: #cccccc; font-size: large;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h3 style="text-align: left;"&gt;
Locate it on the Terminal&lt;/h3&gt;
&lt;div&gt;
Now that the first part of creating the program is done, lets locate it on the Terminal.&lt;/div&gt;
&lt;div&gt;
A terminal is like the command prompt in Windows.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;
Step 1:&lt;/h4&gt;
&lt;div&gt;
You can either &lt;b&gt;open the Terminal&lt;/b&gt; by searching for it in the search utility, or simply use &lt;b&gt;Ctrl+Shift+T &lt;/b&gt;to open the terminal.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcWGYp2cwI-P1DvYFg9IHNr9ZEV5JNwsf__Wnxh1m6Z1MQ1CyZArgBT7numHgAmVMhXhC3Cq2OSjk74Yl0DlI7DsvWDE2gQcHBF5E8h5sEhb-R0bPD_gLjdDQ5sC6jTkNvPcPxf5FNf6Y/s1600/pic2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="205" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcWGYp2cwI-P1DvYFg9IHNr9ZEV5JNwsf__Wnxh1m6Z1MQ1CyZArgBT7numHgAmVMhXhC3Cq2OSjk74Yl0DlI7DsvWDE2gQcHBF5E8h5sEhb-R0bPD_gLjdDQ5sC6jTkNvPcPxf5FNf6Y/s400/pic2.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
This is how the Terminal in Ubuntu looks like.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Better than the rusty Command prompt in Windows right?&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
The text that appears on the left side is called the shell prompt. It displays your user name and the current directory you are on.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
In the pic below ryan is the username and &lt;b&gt;~&lt;/b&gt; is the present directory. &lt;b&gt;&amp;nbsp;~ is an alias for your home directory.&lt;/b&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimENNEqcjTRBOLoG_5JXKoaCWJw8OA2DawjQiNxtf3YnWGZJEo9CDvv7yDDiRDzSv5lC5S7-W1rrmDIIdktwTi6mFJ2LlKF4zOp-GNW4baxZOlXxm5sIyXj4pOwmrVNPN1cZpknNGfrng/s1600/pic3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="256" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimENNEqcjTRBOLoG_5JXKoaCWJw8OA2DawjQiNxtf3YnWGZJEo9CDvv7yDDiRDzSv5lC5S7-W1rrmDIIdktwTi6mFJ2LlKF4zOp-GNW4baxZOlXxm5sIyXj4pOwmrVNPN1cZpknNGfrng/s400/pic3.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style="text-align: left;"&gt;
Step 2:&lt;/h4&gt;
To locate the file on the Terminal open the &lt;b&gt;properties of the file&lt;/b&gt; you just created (FirstProgram.c).&lt;br /&gt;
Copy the Location.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3e5Fm89RwVbvsSuxAn30Htl4cUI_mTIMRlnYHWKjBjpDHEQ5M6DA3MfuwHVJtj3XcGZhQ5Ip3ey1ndXrKkUTzAwz6OAWgQhvrT0opFb6u3lTtEcV5vCRo9giyLR1KHYrPUa01UKsECfE/s1600/pic8.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="273" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3e5Fm89RwVbvsSuxAn30Htl4cUI_mTIMRlnYHWKjBjpDHEQ5M6DA3MfuwHVJtj3XcGZhQ5Ip3ey1ndXrKkUTzAwz6OAWgQhvrT0opFb6u3lTtEcV5vCRo9giyLR1KHYrPUa01UKsECfE/s320/pic8.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;
Step 3:&lt;/h4&gt;
What u do next will make you feel like a pro programmer.&lt;br /&gt;
Use the &lt;b&gt;pwd  command &lt;/b&gt;to display the directory you are currently using. PWD stands for &lt;b&gt;Present Working Directory&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWIkT9GLnmTrgvZbmUw6vChwEjNJVJhVGPNrPrSYkcGvQwratnaC8lP2DNeVPdWkZA3h9GoSQe6Amg-vLKXhIXhyphenhyphenB4PG0zAS4gRhSj9gH0GCW03qLhoVc2g3rBgvzUDTBLFaKTQnsK0M8/s1600/pic9.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="59" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWIkT9GLnmTrgvZbmUw6vChwEjNJVJhVGPNrPrSYkcGvQwratnaC8lP2DNeVPdWkZA3h9GoSQe6Amg-vLKXhIXhyphenhyphenB4PG0zAS4gRhSj9gH0GCW03qLhoVc2g3rBgvzUDTBLFaKTQnsK0M8/s640/pic9.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
The &lt;b&gt;ls command&lt;/b&gt; will display the contents of the directory. LS is an abbreviation for Listing.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9B1gYMfJdMFfBi8Nstt7eMue4aLWH61SU33mySKKOazOJIxvTuUQOVSGeRHG5vrniCCOm7d16WYDAhnmwxtAcHoQJ_9g-E3oueoXZzJPYT7lpyDILh-lJR4pVrGDwt28L4xnZFwhog44/s1600/pic10.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="76" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9B1gYMfJdMFfBi8Nstt7eMue4aLWH61SU33mySKKOazOJIxvTuUQOVSGeRHG5vrniCCOm7d16WYDAhnmwxtAcHoQJ_9g-E3oueoXZzJPYT7lpyDILh-lJR4pVrGDwt28L4xnZFwhog44/s640/pic10.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
You can see the directory you created. MyPrograms.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
If you cannot see your directory, it means you are in the wrong directory and you need to enter the following command:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;table align="center" class="gridtable"&gt; 
 &lt;tbody&gt;
&lt;tr onclick="window.open('http://www.computerhope.com/unix/ucd.htm')"&gt;
  &lt;th class="rounded click"&gt;cd &amp;lt;The file location you copied&amp;gt;&lt;/th&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
If you were able to see the directory then enter the following command:&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;table align="center" class="gridtable"&gt; 
 &lt;tbody&gt;
&lt;tr&gt;
  &lt;th class="rounded"&gt;cd MyPrograms&lt;/th&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgg-K9yxW2YDFO-h0fAlH2cl_H87mIF9E-YKVoB-Xfgqg9spjshkPdQvXyvA-lYPQ70MEsTswENTWWg_13xbthkNg9Z2ITJZfpOklv4FKdi7eSiz3sM0xjVnJeoGkgZYN7U6TAhnhCK5O0/s1600/pic11.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="58" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgg-K9yxW2YDFO-h0fAlH2cl_H87mIF9E-YKVoB-Xfgqg9spjshkPdQvXyvA-lYPQ70MEsTswENTWWg_13xbthkNg9Z2ITJZfpOklv4FKdi7eSiz3sM0xjVnJeoGkgZYN7U6TAhnhCK5O0/s640/pic11.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
*Notice the &lt;b&gt;current directory has changed from ~ to MyPrograms.&lt;/b&gt;&lt;/div&gt;
&lt;h4&gt;
&lt;/h4&gt;
&lt;h4&gt;
&lt;/h4&gt;
&lt;h4&gt;
&lt;/h4&gt;
&lt;h4&gt;
Step 5:&lt;/h4&gt;
&lt;div&gt;
All that's left to do is locate your file. Use the ls command to list the contents of MyDirectory. It will&lt;/div&gt;
&lt;div&gt;
display your file FirstProgram.c&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgSxoxLQGTITbv4q9NOC4Tb3LVBIg0ExragjITopMCLSQLWvIIHDu6rYNuksFsKUef_Dec6kzQQJwN_XNX9Ec2gqBZRpuo7VKrzdeCMKCvwcJJ2hmhXm-a09o5xqoVHYQa5uc8_Tnr3Xc/s1600/pic12.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="58" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgSxoxLQGTITbv4q9NOC4Tb3LVBIg0ExragjITopMCLSQLWvIIHDu6rYNuksFsKUef_Dec6kzQQJwN_XNX9Ec2gqBZRpuo7VKrzdeCMKCvwcJJ2hmhXm-a09o5xqoVHYQa5uc8_Tnr3Xc/s640/pic12.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;b style="color: #cccccc;"&gt;&lt;span style="font-size: large;"&gt;Good job, you located your program in the Terminal.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;b style="color: #cccccc; font-size: x-large;"&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;b style="color: #cccccc; font-size: x-large;"&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;h3&gt;
Run the C Program on the Terminal&lt;/h3&gt;
&lt;div&gt;
Just a few steps until you run the program. I know it wasn't easy, but don't give up. You only need to learn this once, it wont be as difficult the next time.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;
Step 1:&lt;/h4&gt;
&lt;div&gt;
This is the command you need to enter to run your program.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;table align="center" class="gridtable"&gt; 
 &lt;tbody&gt;
&lt;tr onclick="window.open('http://www.computerhope.com/jargon/g/gcc.htm')"&gt;
  &lt;th class="rounded click"&gt;gcc &amp;lt;Your Program Name&amp;gt;&lt;/th&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc50M8HoWnffise4557rgLfsMq0d2yeHF6lHvJtvWVnjvwOR-ioGYF8Wt1j8vjKO4Zfs4BsZkv-8egpkSvNVFM3JTnKX6oVq5Ny2Ue4l2LNmwKENsROmEYy1wXgCdWXp5xDAEek4QL_Ys/s1600/pic13.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;strike&gt;&lt;img border="0" height="76" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc50M8HoWnffise4557rgLfsMq0d2yeHF6lHvJtvWVnjvwOR-ioGYF8Wt1j8vjKO4Zfs4BsZkv-8egpkSvNVFM3JTnKX6oVq5Ny2Ue4l2LNmwKENsROmEYy1wXgCdWXp5xDAEek4QL_Ys/s640/pic13.png" width="640" /&gt;&lt;/strike&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
You will notice that no output is printed, instead executing the ls command will show a new file called a.out is created.&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Don't worry, your program is converted into a&amp;nbsp;&lt;b&gt;binary code&lt;/b&gt;, a format that your computer understands. If this file gets created you can say &lt;b&gt;your code is compiled.&lt;/b&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;
Step 2:&lt;/h4&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Now that your code is compiled its time to run it. Simply execute this command&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;table align="center" class="gridtable"&gt; 
 &lt;tbody&gt;
&lt;tr&gt;
  &lt;th class="rounded"&gt;./a.out&lt;/th&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLUwYo_Hkn4dflfmvnI6ZLB0JX_Kr0U00JcBdE4AlyBly-u5YMfCg38wrvEDMbTDxSheV88MUohPzaJUbR4M8xE_etdmK6Tm4uPsVDo5ulKhfSsuyHNwXVcEPG9kSo53bi2kXQzx_ZVIs/s1600/pic14.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="76" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLUwYo_Hkn4dflfmvnI6ZLB0JX_Kr0U00JcBdE4AlyBly-u5YMfCg38wrvEDMbTDxSheV88MUohPzaJUbR4M8xE_etdmK6Tm4uPsVDo5ulKhfSsuyHNwXVcEPG9kSo53bi2kXQzx_ZVIs/s640/pic14.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;b style="color: #cccccc;"&gt;&lt;span style="font-size: large;"&gt;Congratulations, you didn't give up and successfully ran the program. A great achievement indeed.&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;
More Information:&lt;/h4&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
If you don't like the name a.out run the&lt;b&gt; gcc command with the -o option&lt;/b&gt;. This will make the command&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
syntax&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;table align="center" class="gridtable"&gt; 
 &lt;tbody&gt;
&lt;tr onclick="window.open('http://www.computerhope.com/jargon/g/gcc.htm')"&gt;
  &lt;th class="rounded click"&gt;gcc &amp;lt;Your Program Name&amp;gt; -o &amp;lt;output file name&amp;gt;th&amp;gt;
 &lt;/th&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
&lt;b style="text-align: center;"&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk93XOeAl6XphI7bDS0mdWYOMnzXGfHrPgJ3KxXXzVb58LfOOQdCK2a8eCklGGWAFNsUn9TbDqxgnzUvI2IkhMqSREvNUG0HyB9tpgAfjlEpkxV7uWmXdqYiYGVg7AGArGInzYVCRvi6o/s1600/pic15.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="76" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk93XOeAl6XphI7bDS0mdWYOMnzXGfHrPgJ3KxXXzVb58LfOOQdCK2a8eCklGGWAFNsUn9TbDqxgnzUvI2IkhMqSREvNUG0HyB9tpgAfjlEpkxV7uWmXdqYiYGVg7AGArGInzYVCRvi6o/s640/pic15.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
And use the&lt;b&gt; ./ prefix &amp;nbsp;with the output file name to run it&lt;/b&gt;.&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6FlVlCGcW2n5NQGcSF4bJpelyeoinA4JTxKpZIDweeeTYMZP9wu5BjJ88wa4Ky22xDVPstZq3H1YsrmQKpKW45M7_oTOIxlyfpRrISOPhwkt4FhIxtJCLWt26cKDEvRa4GBp1q02WLOI/s1600/pic16.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="76" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6FlVlCGcW2n5NQGcSF4bJpelyeoinA4JTxKpZIDweeeTYMZP9wu5BjJ88wa4Ky22xDVPstZq3H1YsrmQKpKW45M7_oTOIxlyfpRrISOPhwkt4FhIxtJCLWt26cKDEvRa4GBp1q02WLOI/s640/pic16.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2013/08/enter-dragon-running-out-first-program.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOKZ8dFN41uA2ddIApZbNBLC0XwlCNHEa-etr7MudqDoLqLYQHaCy5KhvlX4oBhD9tEuMec6qLcGqsUUTnNiUBUOWZT4BXYMH0YWbcKASZ88MTkiYKN7-yT10g4_XKOlXnIneCadZMkfg/s72-c/pic4.png" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-4013772614076265036</guid><pubDate>Sun, 25 Aug 2013 07:01:00 +0000</pubDate><atom:updated>2013-08-25T12:36:52.237+05:30</atom:updated><title>Our Vision</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div style="text-align: left;"&gt;
&lt;b&gt;&lt;span style="background-color: white; color: #181818; font-family: georgia, serif; line-height: 18px;"&gt;“If you can't explain it to a six year old, you don't understand it yourself.”&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: right;"&gt;
&amp;nbsp;&lt;b&gt;&lt;span style="background-color: white; color: #181818; font-family: georgia, serif; font-size: 14px; line-height: 18px;"&gt;―&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.goodreads.com/author/show/9810.Albert_Einstein" style="background-color: white; color: #666600; font-family: georgia, serif; font-size: 14px; line-height: 18px; text-decoration: none;"&gt;Albert Einstein&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: Trebuchet MS, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: Trebuchet MS, sans-serif;"&gt;They key is to work with simplicity in mind. Hence every tutorial will be delivered in the simplest way possible.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: Trebuchet MS, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: Trebuchet MS, sans-serif;"&gt;There is no point in moving ahead if you are moving in the wrong direction. Learning the right thing or the right way to do something is what you will learn.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: Trebuchet MS, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: Trebuchet MS, sans-serif;"&gt;Working together can produce results that are greater than the sum of the individual efforts put together. We will learn better if we work together.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: Trebuchet MS, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-family: Trebuchet MS, sans-serif;"&gt;Now that you know our intent, lets start learning.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2013/08/the-vision.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-1627675905409900824</guid><pubDate>Sun, 25 Aug 2013 06:09:00 +0000</pubDate><atom:updated>2013-08-25T11:43:46.677+05:30</atom:updated><title>Install Ubuntu on a Virtual Machine</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div&gt;
A Virtual Machine software allows you to create Virtual PC's &amp;nbsp;(with virtual ram, processor, hard drives, etc) and allows you to install any operating systems of your choice. The advantage of using a virtual machine is that you can do whatever you want on the VM without damaging your original Operating System.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3&gt;
&lt;span style="font-size: large; font-weight: normal;"&gt;Creating the Virtual Machine&lt;/span&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;span style="font-size: large; font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
The first step to is to install Oracle's VM VirtualBox.&lt;br /&gt;
&lt;div&gt;
Choose your download depending on the Operating system you are using.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Here's the link to &lt;b&gt;&lt;a href="http://goo.gl/k8dGfy" rel="nofollow" target="_blank"&gt;download Oracle VM VirtualBox&lt;/a&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Once the installation is done we will have to &lt;b&gt;&lt;a href="http://goo.gl/K8xgSF" rel="nofollow" target="_blank"&gt;download Ubuntu iso&lt;/a&gt;&lt;/b&gt;, (you can choose any linux flavor you want. Since Ubuntu is simple to install and use I would recommend Ubuntu for beginners).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now that you have installed Oracle VM VirtualBox and Downloaded the Ubuntu iso lets create a Virtual Machine&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;
Step 1:&amp;nbsp;&lt;/h4&gt;
&lt;div&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;After you have opened the Oracle VM VirtualBox click on New.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhm-3_qu4qvvancBCCnK1hHI9-RbyB2gtyAIVjS9pCsY285CoCzv_76w1FrJcKKmI3pL_UX8KZo1OqSk_D97oFyI7BtNYrccn7J59WWcP-IThyJv9sZ4UIpeohn19vpmxERRwgHPB5cJDE/s1600/VM1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="261" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhm-3_qu4qvvancBCCnK1hHI9-RbyB2gtyAIVjS9pCsY285CoCzv_76w1FrJcKKmI3pL_UX8KZo1OqSk_D97oFyI7BtNYrccn7J59WWcP-IThyJv9sZ4UIpeohn19vpmxERRwgHPB5cJDE/s320/VM1.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;
Step 2:&lt;/h4&gt;
&lt;div&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;Now enter any name for the Virtual Machine, I have entered Ubuntu. Also select &lt;u&gt;Type: &lt;b&gt;Linux&lt;/b&gt;&lt;/u&gt; and&lt;br /&gt;
&lt;u&gt;Version: &lt;/u&gt;&lt;b style="text-decoration: underline;"&gt;Ubuntu&lt;/b&gt;&amp;nbsp;and click Next.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbGeOzHTgZZjsMoRu7y3-5p-Ki-edu9407Omn4rcFzxylgc_NPftjzHd2bki0Jo9a7ndTbIsKKiMYtpdvAOsSRNKPhXSAi17w71ryaN0Bjj8yaQBda_rxP8O6G0_pefUS9m8rP4AFjsek/s1600/VM2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="325" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbGeOzHTgZZjsMoRu7y3-5p-Ki-edu9407Omn4rcFzxylgc_NPftjzHd2bki0Jo9a7ndTbIsKKiMYtpdvAOsSRNKPhXSAi17w71ryaN0Bjj8yaQBda_rxP8O6G0_pefUS9m8rP4AFjsek/s400/VM2.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;
Step 3:&lt;/h4&gt;
&lt;div&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;The next step is to select the amount of RAM you want to allocate to your VM.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Since you are only going to use it run C and other basic operations, &lt;b&gt;512 MB&lt;/b&gt; would be sufficient.&lt;br /&gt;
If you have more than 2GB of RAM on your system you can be more generous. Anything around 1024 MB will be good enough.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbU60r2ffNtKXrJNDpaXXb3E2fgBSpprmT-IpsN2aDw5Avm770WhDiLAwr1NSv7WYBcDAEjYuY9ZZ0NPwvg1e2A4eh1Y39cQfG_WY-h6hmfYwGF9uKQydWSiZ_A0rOu4Lya36HQUnen6M/s1600/VM3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="325" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbU60r2ffNtKXrJNDpaXXb3E2fgBSpprmT-IpsN2aDw5Avm770WhDiLAwr1NSv7WYBcDAEjYuY9ZZ0NPwvg1e2A4eh1Y39cQfG_WY-h6hmfYwGF9uKQydWSiZ_A0rOu4Lya36HQUnen6M/s400/VM3.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;
Step 4:&lt;/h4&gt;
&lt;div&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;The next step is to create a virtual Hard Drive. This is the place on your system where the VM will be installed. To create a virtual Hard Drive follow these steps&lt;/div&gt;
&lt;div&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Select &lt;b&gt;Create a Virtual Hard drive now&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;Select &lt;b&gt;VirtualBox Disk Image&lt;/b&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Depending on your choice select &lt;b&gt;Fixed size or Dynamic&lt;/b&gt;. If you have limited free space available on your hard drive i recommend you to go with Fixed Size.&lt;/li&gt;
&lt;li&gt;Finally browse the &lt;b&gt;path&lt;/b&gt; where you want to create this Virtual Hard Drive and select the &lt;b&gt;space&lt;/b&gt; you want to allocate to it. I recommend using 8 GB. The minimum space requirement for Ubuntu is 5.3 GB, hence if you don't have 8 GB of free space, i recommend you use at least 5.4 GB&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyzIp4tDRm_4-hRV41UXL3uJNq5-7g0M2J4svIDAlQ8RPu_nVjeI74UajrG0IrI6guBFaHnNtnCNckbJTMnf42WK2zaoRfI2KNVVRET8gOkPdSdGLTso9ADZ5x036cV-gBlRo8-edBr5Y/s1600/VM4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyzIp4tDRm_4-hRV41UXL3uJNq5-7g0M2J4svIDAlQ8RPu_nVjeI74UajrG0IrI6guBFaHnNtnCNckbJTMnf42WK2zaoRfI2KNVVRET8gOkPdSdGLTso9ADZ5x036cV-gBlRo8-edBr5Y/s1600/VM4.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibnLFaNtg0JMMccJwD96fWp8Ea9xY972QU8UuVJvL-PsJKylh_1wX1a1Ouhh0YH8qgEPc12PP7oDniIurKvKv7r2L_vXOniHcY8RmkJlRoBPz2PM0BqauYQS7VDhUxK1oyJCB136Y9-k0/s1600/VM6.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibnLFaNtg0JMMccJwD96fWp8Ea9xY972QU8UuVJvL-PsJKylh_1wX1a1Ouhh0YH8qgEPc12PP7oDniIurKvKv7r2L_vXOniHcY8RmkJlRoBPz2PM0BqauYQS7VDhUxK1oyJCB136Y9-k0/s1600/VM6.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIo2x4eM9nJXej9zFqP6FkB6or6AUs6xjwnfOLlymOrfpSldJs2A_RT1vFeCQpfr43DN13C7t4WtKYAda8BRbd94C-T1fKpdlrI1kQsgLfM7xg73ApaGvKVlrZSMmw_Ko4PW6Q_Xq-zGA/s1600/VM7.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIo2x4eM9nJXej9zFqP6FkB6or6AUs6xjwnfOLlymOrfpSldJs2A_RT1vFeCQpfr43DN13C7t4WtKYAda8BRbd94C-T1fKpdlrI1kQsgLfM7xg73ApaGvKVlrZSMmw_Ko4PW6Q_Xq-zGA/s1600/VM7.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh6iC1f9l9lfI8JPhRZnoy2Gbfw7zwW2AL6wooUxKAIeMCcUfBUNeLP7fQ1obmR1Qne3ELInVcLESgdvScr9zyL_yCJ2fTa3mGmTXTmaRE6U3-3LQ23KBGj9wbc0i5_r51EVgDuCO5Sas/s1600/VM8.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh6iC1f9l9lfI8JPhRZnoy2Gbfw7zwW2AL6wooUxKAIeMCcUfBUNeLP7fQ1obmR1Qne3ELInVcLESgdvScr9zyL_yCJ2fTa3mGmTXTmaRE6U3-3LQ23KBGj9wbc0i5_r51EVgDuCO5Sas/s1600/VM8.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style="color: #999999; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"&gt;&lt;i&gt;&lt;b&gt;Congratulations, Your VM is created !!!&lt;/b&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif; font-size: large;"&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h3&gt;
&lt;span style="font-size: large; font-weight: normal;"&gt;Installing an Operating System on the Virtual Machine&lt;/span&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-size: large; font-weight: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Now the only thing left to do is install the Operating System on it. Here we are going to install Ubuntu from the iso you downloaded earlier.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Since this is the first time we are starting the Virtual Machine we need to install the Operating System.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Step 1:&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;Click on Start. and Locate the ubuntu iso file you downloaded earlier. Selecting start will turn on the machine.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpeDvbJf27BfKvsJqfTgh9PGlpn3LKv6Vgs8oxx45yh6Kk35UWoJjhqK4fAjac52Ele-mV6_KUXyb2X1oBNcVJ-XyfwkfjyMEKCux_nNh-HYmMDSHRe9Me3bTLII3k4MKDRiRvlsRS2nM/s1600/VM9.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="297" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpeDvbJf27BfKvsJqfTgh9PGlpn3LKv6Vgs8oxx45yh6Kk35UWoJjhqK4fAjac52Ele-mV6_KUXyb2X1oBNcVJ-XyfwkfjyMEKCux_nNh-HYmMDSHRe9Me3bTLII3k4MKDRiRvlsRS2nM/s400/VM9.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9j4GCyQhpNtirn7BnyQ2NeUhPhn5804hDWcGH5-iIkl4eMQ-fGEIwyuuhJBxXDFYSv7ZkBk-BYqi6y-bhF1O0eUANJkvWg7qWsg3iAvydQT-EVnfiGG2hliaUc4PlY22ULD_mt5XIKQs/s1600/VM10.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="325" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9j4GCyQhpNtirn7BnyQ2NeUhPhn5804hDWcGH5-iIkl4eMQ-fGEIwyuuhJBxXDFYSv7ZkBk-BYqi6y-bhF1O0eUANJkvWg7qWsg3iAvydQT-EVnfiGG2hliaUc4PlY22ULD_mt5XIKQs/s400/VM10.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h4 style="text-align: left;"&gt;
Step 2:&lt;/h4&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style="white-space: pre;"&gt; Now click on Install Ubuntu. &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="white-space: pre;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAdR6mL5SAUO5d1fn5zp5vt5-CwDwoYVdgxVWH217f2kqJEap-azKSgG_KOJaANCt1onEYiJSVojKxhn52gmeBL2cCNJT-6dsq7Xbz89uctCcjSiXcwOZrP8aWRI_gYWsLMY05FuAWhrw/s1600/VM11.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="264" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAdR6mL5SAUO5d1fn5zp5vt5-CwDwoYVdgxVWH217f2kqJEap-azKSgG_KOJaANCt1onEYiJSVojKxhn52gmeBL2cCNJT-6dsq7Xbz89uctCcjSiXcwOZrP8aWRI_gYWsLMY05FuAWhrw/s320/VM11.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="white-space: pre;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
For those who have a fast internet connection can choose to download updates. Installing third party software is also optional. Now click Continue (isn't that obvious).&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGyNy937Z8Pe0QbEWAFc1wBlwe7GVDplw490DLQCVALJJwWKuqZhe50ylvEuEHuE5KmdH1AsqWc6hFW3t79CdnqykeeqX9N5YinSdAatmD3IgAGqdKbWxrR0MODt9FJJlt7GdqZvv8TXI/s1600/VM12.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="308" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGyNy937Z8Pe0QbEWAFc1wBlwe7GVDplw490DLQCVALJJwWKuqZhe50ylvEuEHuE5KmdH1AsqWc6hFW3t79CdnqykeeqX9N5YinSdAatmD3IgAGqdKbWxrR0MODt9FJJlt7GdqZvv8TXI/s400/VM12.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;
Step 3:&lt;/h4&gt;
&lt;div&gt;
&lt;span style="white-space: pre;"&gt; Click Install. Then select the country you belong to(this information is required to set date and time).&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="white-space: pre;"&gt;Select the Language and Keyboard type. Don't change the default language and keyboard type unless&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="white-space: pre;"&gt;explicitly required.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="white-space: pre;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvLwfljT1b97_BAkbn9tOB6uV4fbqMhI7DTYVylU1p_cXwE0_odmyprHgw4zEoKntxaeS5m50nGIRO_tuNPJrvdP6WfIj5bRiZpoweOIL5F6gDlyke8HiBM96VKWnGYqdMdyyuF9U42DE/s1600/VM13.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="308" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvLwfljT1b97_BAkbn9tOB6uV4fbqMhI7DTYVylU1p_cXwE0_odmyprHgw4zEoKntxaeS5m50nGIRO_tuNPJrvdP6WfIj5bRiZpoweOIL5F6gDlyke8HiBM96VKWnGYqdMdyyuF9U42DE/s400/VM13.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style="text-align: left;"&gt;
Step 4:&amp;nbsp;&lt;/h4&gt;
&lt;div&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Enter your &lt;b&gt;name&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Optionally edit your computer name.&lt;/li&gt;
&lt;li&gt;Pick a &lt;b&gt;username&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Enter a &lt;b&gt;password&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
For users who don't want to enter their password every time they log in, select the option Log in automatically.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Click Continue and site aside till the installation gets completed.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqAgFFd8JzKsC8t9ewInfHdCP-1R6wjg4mG3EjfkpODC1lOVDpVW85Gy9WRqJo_BNoZVP4B2ZxyzputteMrmq-zahyphenhyphen8NKHhNHjq9RVXUAoxy65F001TuXHShmmFd-U_GMWi8nVxaF4lNs/s1600/VM14.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="308" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqAgFFd8JzKsC8t9ewInfHdCP-1R6wjg4mG3EjfkpODC1lOVDpVW85Gy9WRqJo_BNoZVP4B2ZxyzputteMrmq-zahyphenhyphen8NKHhNHjq9RVXUAoxy65F001TuXHShmmFd-U_GMWi8nVxaF4lNs/s400/VM14.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Once the installation is completed you will be prompted to &lt;b&gt;Restart&lt;/b&gt;.&lt;/div&gt;
&lt;div&gt;
If you have followed all the steps properly Ubuntu will b up and running, ready for you ti use.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8vSsaPovzvW6ldQk3NX6-FyqdRiJXmyGC8bpdvUMkUOHIt4xM7ewXQYjefZHbBlDIV-uFIS7HwH5eR8wkpg2kS77VUPEG0XCtAasfKiaf_mUt2X6rNwh2qRWrZ2DVVpGz9F_comt592o/s1600/VM15.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="326" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8vSsaPovzvW6ldQk3NX6-FyqdRiJXmyGC8bpdvUMkUOHIt4xM7ewXQYjefZHbBlDIV-uFIS7HwH5eR8wkpg2kS77VUPEG0XCtAasfKiaf_mUt2X6rNwh2qRWrZ2DVVpGz9F_comt592o/s400/VM15.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style="white-space: pre;"&gt;And finally, you don't need to worry about uninstalling Ubuntu. You can simply delete the virtual machine by&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="white-space: pre;"&gt;Right clicking on the virtual machine and selecting Remove in the Oracle VM VirtualBox Manager&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2013/08/install-ubuntu-on-virtual-machine.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhm-3_qu4qvvancBCCnK1hHI9-RbyB2gtyAIVjS9pCsY285CoCzv_76w1FrJcKKmI3pL_UX8KZo1OqSk_D97oFyI7BtNYrccn7J59WWcP-IThyJv9sZ4UIpeohn19vpmxERRwgHPB5cJDE/s72-c/VM1.jpg" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-2537405865371923359</guid><pubDate>Sun, 25 Aug 2013 06:06:00 +0000</pubDate><atom:updated>2013-08-25T11:48:56.211+05:30</atom:updated><title>Uninstalling Ubuntu from Windows</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
This method of uninstallation is applicable only if you have installed Ubuntu using the Windows Installer.&lt;br /&gt;
&lt;br /&gt;
Just like &lt;a href="http://mycodedotc.blogspot.in/2013/08/installing-ubuntu-with-windows.html" target="_blank"&gt;&lt;b&gt;the installation process&lt;/b&gt;&lt;/a&gt;, the uninstallation is also simple.&lt;br /&gt;
There are two ways to do this&lt;br /&gt;
&lt;br /&gt;
You can either use the wubi-uninstaller. Simply click on &lt;b&gt;uninstall-wubi.exe&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimZYx_DCeIsK8csm-WoA6JcjNaOAjWmXw0AYQdN8SjBRY6nU1XR3uUuxY3dq2-TVYa6XWrpl5cVbaUed1ZYCwQIv_kyyKViPUabV-1YPBVIMPbuJ5pJ_aqxWE3l0MjJdcUHiWbmXl7XxE/s1600/UBUninstall1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimZYx_DCeIsK8csm-WoA6JcjNaOAjWmXw0AYQdN8SjBRY6nU1XR3uUuxY3dq2-TVYa6XWrpl5cVbaUed1ZYCwQIv_kyyKViPUabV-1YPBVIMPbuJ5pJ_aqxWE3l0MjJdcUHiWbmXl7XxE/s400/UBUninstall1.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
Or you can use the &lt;b&gt;Windows Add or Remove programs&lt;/b&gt;.&lt;br /&gt;
This will indirectly invoke uninstall-wubi.exe&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFXNoPqRC9k6fORYemfRqV-LLtPzLY6jgzN2_EX-GSzQfroJObWYPuf13WtSRLdT4xi2rnBGTT6v8oqD1f6vcf_MauWf7512soCj2aMV2G66clDDO6JatOUd6mDSfckETys3ztEyRrKt4/s1600/UBUninstall2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="290" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFXNoPqRC9k6fORYemfRqV-LLtPzLY6jgzN2_EX-GSzQfroJObWYPuf13WtSRLdT4xi2rnBGTT6v8oqD1f6vcf_MauWf7512soCj2aMV2G66clDDO6JatOUd6mDSfckETys3ztEyRrKt4/s400/UBUninstall2.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2013/08/uninstalling-ubuntu-from-windows.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimZYx_DCeIsK8csm-WoA6JcjNaOAjWmXw0AYQdN8SjBRY6nU1XR3uUuxY3dq2-TVYa6XWrpl5cVbaUed1ZYCwQIv_kyyKViPUabV-1YPBVIMPbuJ5pJ_aqxWE3l0MjJdcUHiWbmXl7XxE/s72-c/UBUninstall1.jpg" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-8803973504005104953</guid><pubDate>Sat, 24 Aug 2013 03:31:00 +0000</pubDate><atom:updated>2013-08-25T11:49:15.260+05:30</atom:updated><title>Installing Ubuntu with Windows</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
This method will allow you to install Ubuntu from Windows, just like the way you install any other software.&lt;br /&gt;
&lt;div&gt;
The advantage of installing it this way is that you can uninstall it easily from Add or Remove programs or Ubuntu wubi uninstaller as a normal software.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Here's the &lt;b&gt;&lt;a href="http://goo.gl/QTSRlE" target="_blank"&gt;official installation guide on the Ubuntu website&lt;/a&gt;.&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
For those who have a slow internet connection follow these steps&lt;/div&gt;
&lt;div&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Download the iso of the Ubuntu installation you want.&lt;/li&gt;
&lt;li&gt;Extract the iso using WinRar.&lt;/li&gt;
&lt;li&gt;Now click on the wubi.exe and follow the same steps as mentioned in the official installation guide.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAUWGhqqG0o1x0jAzxjucf1ICbpVUVWJ7RQV1x-YvWaqrrmlruL7dqpSuBu0ldDIHihvld-yve9aBXhIBBdccMersXpN0NA6g9-e9QwfrWaYcTEWevDNADA-va7Hzc2mcxIVEEiI2d61Q/s1600/UbubtuInstall.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img alt="" border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAUWGhqqG0o1x0jAzxjucf1ICbpVUVWJ7RQV1x-YvWaqrrmlruL7dqpSuBu0ldDIHihvld-yve9aBXhIBBdccMersXpN0NA6g9-e9QwfrWaYcTEWevDNADA-va7Hzc2mcxIVEEiI2d61Q/s400/UbubtuInstall.jpg" title="Extracted Ubuntu Iso contentes" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span id="goog_163955182"&gt;&lt;/span&gt;&lt;span id="goog_163955183"&gt;&lt;/span&gt;&lt;br /&gt;
If you are using the windows installer method, in case of a slow connection if the connection is interrupted the download will stop and may not resume. Hence its safe to download the iso (which will definitely resume) and follow the steps I mentioned above.&lt;br /&gt;
&lt;br /&gt;
Now that you know how Ubuntu is installed from windows, here's &lt;a href="http://mycodedotc.blogspot.in/2013/08/uninstalling-ubuntu-from-windows.html" target="_blank"&gt;&lt;b&gt;the uninstallation guide&lt;/b&gt;&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2013/08/installing-ubuntu-with-windows.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAUWGhqqG0o1x0jAzxjucf1ICbpVUVWJ7RQV1x-YvWaqrrmlruL7dqpSuBu0ldDIHihvld-yve9aBXhIBBdccMersXpN0NA6g9-e9QwfrWaYcTEWevDNADA-va7Hzc2mcxIVEEiI2d61Q/s72-c/UbubtuInstall.jpg" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-7154621368847645299</guid><pubDate>Mon, 19 Aug 2013 02:51:00 +0000</pubDate><atom:updated>2013-08-24T20:22:14.882+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Get to Know Us</category><title>So What Are the RULES ?</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Yes, there are rules to follow. Remember all that is posted in this blog is to make your life simpler. Hence all the tutorials are structured in a fixed format so that you know where to search for the information you desire.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So what do you need to know:&lt;/div&gt;
&lt;div&gt;
&lt;div style="text-align: left;"&gt;
&lt;b&gt;Every post will have the title in the following format "Chapter number - Concept explained".&lt;/b&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
The reason for this is that if you want to follow the tutorials in a&amp;nbsp;sequential&amp;nbsp;manner you can do this by searching the posts based on the Chapter name. And for those who want to search the tutorials on particular concepts can do so by searching for the that concept.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Every post will have a explicit link to the previous post and the next post.&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Every tutorial will have a example to emphasize the concept.&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;In case any one thinks some information is&amp;nbsp;irrelevant&amp;nbsp;or &amp;nbsp;some concept can be explained better feel free to comment.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;(use the options on the&amp;nbsp;right&amp;nbsp;top side of the code to view, copy or print the code)&lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
These are all the rules i could think of. As the blog grows i will add more based on past experience.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Also&lt;b&gt; &lt;a href="http://mycodedotc.blogspot.in/2012/08/contents-of-blog.html" target="_blank"&gt;Click Here&lt;/a&gt;&lt;/b&gt; to check out the contents of the blog.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2012/08/so-what-are-rules.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-7180898934004838718</guid><pubDate>Thu, 01 Nov 2012 17:06:00 +0000</pubDate><atom:updated>2013-08-24T20:21:03.023+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Archive</category><title>Chapter 13 - Nested Conditions( Using nested If ... else...) [Part 3 of 3]</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shCore.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shBrushCpp.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;script type="text/javascript"&gt;
  SyntaxHighlighter.config.clipboardSwf = 'https://dl.dropbox.com/u/102425073/code/scripts/clipboard.swf';
  SyntaxHighlighter.all();
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
&lt;/script&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Last thing u need to know about IF .. ELSE&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div&gt;
The two concepts discussed here are&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Nested blocks&lt;/li&gt;
&lt;li&gt;Indentation&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Both of which can be&amp;nbsp;emphasized with a single example, given below&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 19thth October 2012  
 Title : Program to find the limits
*/  

#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;


void main()
 {

  float num=0, u_lt=0, l_lt=0;
  
  clrscr();

  //prompt the user to enter the upper limit
  printf("Please enter the upper limit :");
  scanf("%f",&amp;amp;u_lt);

  //prompt the user to enter the lower limit
  printf("Please enter the lower limit :");
  scanf("%f",&amp;amp;l_lt);

  //prompt the user to enter a number
  printf("Enter a (decimal) number : ");
  scanf("%f",&amp;amp;num);

  //nested if else

  //number less than upper limit
  if(num &amp;lt;= u_lt)
    {
        //number greater than lower limit 
        if(num &amp;gt;= l_lt)
            printf("\n%f number is within the limit",num);

        else
            printf("\n%f number is less than the lower limit",num);
    }
  else
     printf("\n%f number is greater than the upper limit",num);


  getch();
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
In the following example multiple if 's can be thought of as &lt;b&gt;using multiple filters.&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
The first filter checks if the upper limit is satisfied and only then proceeds with the inner block.&lt;br /&gt;
The second filter then checks the lower limit.&lt;br /&gt;
&lt;br /&gt;
Using this logic you can place as many if's one inside the other. Also you can pair them with their respective else s to handle failed conditions. The general syntax for nested if else is given below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;div style="background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); color: #333333; display: inline-block; font-family: Verdana, sans-serif; font-size: 15px; line-height: 20px; padding: 20px; width: 50%;"&gt;
&lt;div style="text-align: left;"&gt;
&lt;h3&gt;
&lt;b&gt;if (condition)&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&amp;nbsp;{&lt;/b&gt;&lt;/h3&gt;
&lt;h3&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&lt;/b&gt;if (condition)&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/h3&gt;
&lt;h3&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/b&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; ...........&amp;nbsp;&lt;/b&gt;&lt;/h3&gt;
&lt;h3&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;b&gt;else&lt;/b&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;h3&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;b&gt;...........&lt;/b&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;h3&gt;
&lt;b&gt;}&lt;/b&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;b&gt;&lt;/b&gt;&lt;b&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The most important thing in nesting is the arrangement of the code. It is called Indentation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;Indentation:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;span style="background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.200000762939453px;"&gt;Indentation is not a requirement of C programming language&lt;/span&gt;&lt;span style="background-color: white;"&gt;&lt;span style="font-family: sans-serif; font-size: x-small;"&gt;&lt;span style="line-height: 19.200000762939453px;"&gt;. Rather, &lt;/span&gt;&lt;/span&gt;&lt;b style="font-family: sans-serif; font-size: 13px; line-height: 19.200000762939453px;"&gt;&lt;i&gt;programmers indent to better convey the structure of their programs to human readers&lt;/i&gt;&lt;/b&gt;&lt;span style="font-family: sans-serif; font-size: x-small;"&gt;&lt;span style="line-height: 19.200000762939453px;"&gt;. In particular, indentation is &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-family: sans-serif; font-size: x-small;"&gt;&lt;span style="line-height: 19.200000762939453px;"&gt;used to show the relationship between control flow&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;b&gt;&lt;i&gt;&lt;span style="background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19.200000762939453px;"&gt;constructs such as conditions or loops and code contained within and outside them.&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_ybtK3fDb4fQGdWOU9DSmT_WEK1qynac_ovnw5xD3RYX0u2r65ZsfCYrRLWfaFRAUdPoqwfq_3YymmjdmuGlyxivYi5VfJpw4tky5xZvtfn_MpbC4dI20FBGM-YvhsMJcXmtTJwntpWM/s1600/scrn+3.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_ybtK3fDb4fQGdWOU9DSmT_WEK1qynac_ovnw5xD3RYX0u2r65ZsfCYrRLWfaFRAUdPoqwfq_3YymmjdmuGlyxivYi5VfJpw4tky5xZvtfn_MpbC4dI20FBGM-YvhsMJcXmtTJwntpWM/s640/scrn+3.bmp" width="618" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVFbBJWXV_FIJZipU_opLJaH_VQPWWzJCtmRLXOfqAvH6_Ns-hS6kDi6MJFyb01X3DobrIiWxsC9ngWToj-exYA2RXbCsAk5rJTXP6QC5qLk-idnWTDLddrA6csV-tFvPWrIi_4e-Q6kk/s1600/scrn+4.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVFbBJWXV_FIJZipU_opLJaH_VQPWWzJCtmRLXOfqAvH6_Ns-hS6kDi6MJFyb01X3DobrIiWxsC9ngWToj-exYA2RXbCsAk5rJTXP6QC5qLk-idnWTDLddrA6csV-tFvPWrIi_4e-Q6kk/s640/scrn+4.bmp" width="580" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The idea here is to arrange the code&amp;nbsp;belonging to the along (same) vertical line&amp;nbsp;.&lt;br /&gt;
In order to get used to this, use a tab every time you create a block i.e. after typing a brace bracket '&lt;b&gt;{'&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="color: #333333; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: 15px; line-height: 20px;"&gt;&lt;b&gt;&lt;a href="http://mycodedotc.blogspot.in/2012/10/chapter-12-adding-conditions-using-if.html"&gt;Previous Post&lt;/a&gt; &amp;nbsp; &amp;nbsp; Next Post&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2012/11/chapter-13-nested-conditions-using.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_ybtK3fDb4fQGdWOU9DSmT_WEK1qynac_ovnw5xD3RYX0u2r65ZsfCYrRLWfaFRAUdPoqwfq_3YymmjdmuGlyxivYi5VfJpw4tky5xZvtfn_MpbC4dI20FBGM-YvhsMJcXmtTJwntpWM/s72-c/scrn+3.bmp" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-3326915461795724029</guid><pubDate>Wed, 17 Oct 2012 09:41:00 +0000</pubDate><atom:updated>2013-08-24T20:20:44.241+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Archive</category><title>Chapter 12 - Adding Conditions (Using If ... else...) [Part 2 of 3]</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shCore.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shBrushCpp.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;script type="text/javascript"&gt;
  SyntaxHighlighter.config.clipboardSwf = 'https://dl.dropbox.com/u/102425073/code/scripts/clipboard.swf';
  SyntaxHighlighter.all();
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
&lt;/script&gt;
&lt;br /&gt;
In the first part we learned how to deal with conditions and how to execute a block of code only when a certain condition is fulfilled&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In this chapter we will deal will what we can do if a condition is false.&lt;/div&gt;
&lt;div&gt;
For this we will make use of the else block.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://www.byterevel.com/wp-content/uploads/2011/07/ifelse.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://www.byterevel.com/wp-content/uploads/2011/07/ifelse.png" width="268" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
Take a look at the image above. The flow chart shows how the execution of the program proceeds in either cases.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Note: It is important to know that it is not necessary to use an else block for every if statement and should be used only when necessary.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Also the placement of the else block will make a lot of difference. &amp;nbsp;You will learn about this after we deal with &lt;b&gt;"nested if... else..."&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
Lets implement a small program to implement if else.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 17th October 2012  
 Title : Program to check if number is odd or even
*/  

#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

void main()
 {

  int num=0;

  clrscr();

  //prompt the user to enter a number
  printf("Enter a number : ");
  scanf("%d",&amp;amp;num);

  //out if else block to handle even or odd cases
  if(num % 2 == 0)
   printf("\n%d number is even",num);
  else
   printf("\n%d number is odd",num);


  getch();
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Note that you can skip the parenthesis ( the brackets {}) if you have a single line of code inside if or else&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Now that we can handle both if and else cases the next thing to do is, to move ahead with the types of conditions we can use.&lt;br /&gt;
&lt;br /&gt;
We will learn how to implement more complicated (multiple) conditions with some simple examples&lt;br /&gt;
&lt;br /&gt;
The three important notations one are:&lt;br /&gt;
&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;&amp;amp;&amp;amp;&lt;/li&gt;
&lt;li&gt;||&lt;/li&gt;
&lt;li&gt;!&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
These are called&amp;nbsp;Boolean&amp;nbsp;operators and each of these has a meaning and should be used carefully.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
It took me some time to figure out a robust example that any one (not having knowledge of&amp;nbsp;Boolean logic) could understand.&lt;br /&gt;
&lt;br /&gt;
So the example we are going to be using is the number line example. We will also make use of images to visually illustrate the examples.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWBNVqwqWKJQie-VmePkgspgaTuZoAdS9FegMzdufOiQEsbi4pe5mNIs5OXiq8RBqVpofK2dGga3hwqWCXLs-FeeoDl-15O_twUdfUigJWlhhEar7YklyryDuebAd0Xy7A-uRJYiu6jws/s1600/main.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWBNVqwqWKJQie-VmePkgspgaTuZoAdS9FegMzdufOiQEsbi4pe5mNIs5OXiq8RBqVpofK2dGga3hwqWCXLs-FeeoDl-15O_twUdfUigJWlhhEar7YklyryDuebAd0Xy7A-uRJYiu6jws/s1600/main.bmp" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;First the &amp;amp;&amp;amp; (AND) operator&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;u&gt;Condition 1:&lt;/u&gt;&lt;/b&gt;&amp;nbsp; num &amp;gt; 3&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Condition 1:&lt;/u&gt;&lt;/b&gt;&amp;nbsp; num &amp;lt; 5&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Result:&lt;/u&gt;&lt;/b&gt;&amp;nbsp; num &amp;gt; 3 &amp;amp;&amp;amp; num &amp;lt; 5&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVcTWLj30XH1zGYX44MiwBc6uqcXDueOrcOwx2q-g__zKyJ_Ayoh7wkPc73t316pPBj2qkQTV84Fzua0DpFnbiFIHPfT0lCq3WeyIfBeGPD6_HN1qLEGLoSSSBi1yHE-BEmz5uGUtvQjk/s1600/and+1.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVcTWLj30XH1zGYX44MiwBc6uqcXDueOrcOwx2q-g__zKyJ_Ayoh7wkPc73t316pPBj2qkQTV84Fzua0DpFnbiFIHPfT0lCq3WeyIfBeGPD6_HN1qLEGLoSSSBi1yHE-BEmz5uGUtvQjk/s1600/and+1.bmp" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikOJZQU5l5n1qwmx2v7IILsUQpLqOJOaUPFRy5Q7ZTu1l0Ks-jJcMHHG21icdvlM4BZIYcWIoZMCcJHJ_xNKBFD7OJv04DaLHz6sdWA7dLUBoQG8hRFCJAd0I9ewuH2zBieJwyArETRjs/s1600/and+2.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikOJZQU5l5n1qwmx2v7IILsUQpLqOJOaUPFRy5Q7ZTu1l0Ks-jJcMHHG21icdvlM4BZIYcWIoZMCcJHJ_xNKBFD7OJv04DaLHz6sdWA7dLUBoQG8hRFCJAd0I9ewuH2zBieJwyArETRjs/s1600/and+2.bmp" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1DtNmitzwvP8UBXCjd0Dy0tfe4e5dik4ojHqKebqsELQBCxUAs1HbZXaQTdYvu1YDkPWD1ZAavW7RhooA5soiJ8I2Ha6G7ecs_QMK0zzBbocT9DwI-CjPDGsLDYtPmdwmMQ5vptcyTBM/s1600/and+res.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1DtNmitzwvP8UBXCjd0Dy0tfe4e5dik4ojHqKebqsELQBCxUAs1HbZXaQTdYvu1YDkPWD1ZAavW7RhooA5soiJ8I2Ha6G7ecs_QMK0zzBbocT9DwI-CjPDGsLDYtPmdwmMQ5vptcyTBM/s1600/and+res.bmp" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
which means the number has to be &lt;u&gt;&lt;b&gt;both greater than 3 and less than 5.&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Implementation:&lt;/b&gt;
&lt;br /&gt;
&lt;/u&gt;&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;if(num &amp;gt; 3 &amp;amp;&amp;amp; num &amp;lt; 5)
     {
          printf("Number Accepted");
     }
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;Second the || (OR) operator&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Condition 1:&lt;/u&gt;&lt;/b&gt;&amp;nbsp; num &amp;lt; 3&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Condition 1:&lt;/u&gt;&lt;/b&gt;&amp;nbsp; num &amp;gt; 5&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Result:&lt;/u&gt;&lt;/b&gt;&amp;nbsp; num &amp;lt; 3 || num &amp;gt; 5&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk9kNoFAV5uVJBVmTTh47UjIaYMHLD344JhYHWXT6kLf_AOaVlYzqgE4reJFmGyNytIJaXYMIpyvY1SgHqp1YGoM7-uRW2b3-MqVQfbqvagZp7kW1s-Ei_lxP65UyjTHpAKyqhSFDj01Y/s1600/or+1.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk9kNoFAV5uVJBVmTTh47UjIaYMHLD344JhYHWXT6kLf_AOaVlYzqgE4reJFmGyNytIJaXYMIpyvY1SgHqp1YGoM7-uRW2b3-MqVQfbqvagZp7kW1s-Ei_lxP65UyjTHpAKyqhSFDj01Y/s1600/or+1.bmp" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgLrOU_LeE-gW8va2kK70Fj3y7lk2y8iQ2sbTxbOoNZjFqcAesqDEYqlHIwwqmaUtzrSDUJNdMiUPVNe9BceUaRcgb5u1HhTJiqybH96qngXszx20UWcLiM-lZkTGZcErkd7rV66XIGoM/s1600/or+2.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgLrOU_LeE-gW8va2kK70Fj3y7lk2y8iQ2sbTxbOoNZjFqcAesqDEYqlHIwwqmaUtzrSDUJNdMiUPVNe9BceUaRcgb5u1HhTJiqybH96qngXszx20UWcLiM-lZkTGZcErkd7rV66XIGoM/s1600/or+2.bmp" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3UL1Hb-b09pkOViLw8ViWn44n_wkCx75GZ0RrpIoR7L6Nz1BIjr0_PCRYfwwuO9ovcDgKF9t0OcQ7vHUN3Jt0bAmsddc0o0cUklTUd6Enf28_jwIN-TtF60vHfhHS2dp0TAX6-rRzPzo/s1600/or+res.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3UL1Hb-b09pkOViLw8ViWn44n_wkCx75GZ0RrpIoR7L6Nz1BIjr0_PCRYfwwuO9ovcDgKF9t0OcQ7vHUN3Jt0bAmsddc0o0cUklTUd6Enf28_jwIN-TtF60vHfhHS2dp0TAX6-rRzPzo/s1600/or+res.bmp" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
which means the number has to be &lt;b&gt;&lt;u&gt;either less than 3 or greater than 5.&amp;nbsp;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Also it can be both condition 1 (less than 3) and condition 2 (greater than 5) , but in this example it is not possible&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;b style="text-decoration: underline;"&gt;Implementation:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;if(num &amp;lt; 3 || num &amp;gt; 5)
     {
          printf("Number Accepted");
     }
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;And then the ! (NOT) operator&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Here we will us the same 2 conditions from &lt;b&gt;'And'&lt;/b&gt; example and &lt;b&gt;'Not'&lt;/b&gt; the result&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Value:&lt;/u&gt;&lt;/b&gt;&amp;nbsp; Not (condition/conditions)&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Result:&lt;/u&gt;&lt;/b&gt;&amp;nbsp; !(num &amp;gt; 3 &amp;amp;&amp;amp; num &amp;lt; 5)&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhv6suks2f9JYWhwVLvjNMwQmqmKHZ_nsd4tQA-vEbBHH-T9WYPV02qCJoOf-6Lfjc0G7DSzLwaW7m41Iv7USfXX9YIhbV7kIHDVO1r720hvtabp9Xt5v2gSdpxYPX9azyXt6wRbfbjAM/s1600/not+res.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhv6suks2f9JYWhwVLvjNMwQmqmKHZ_nsd4tQA-vEbBHH-T9WYPV02qCJoOf-6Lfjc0G7DSzLwaW7m41Iv7USfXX9YIhbV7kIHDVO1r720hvtabp9Xt5v2gSdpxYPX9azyXt6wRbfbjAM/s1600/not+res.bmp" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
so !{(condition 1) &amp;amp;&amp;amp; (condition 2)} &amp;nbsp;translates to NOT ( greater than 3 and less than 5 )&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
which means the number should &lt;b&gt;not be greater than 3 and less than 5&lt;/b&gt;.&lt;br /&gt;
These are all the values that would have been considered false by the same condition without '!' not operator.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;u&gt;Implementation:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;if(!(num &amp;gt; 3 &amp;amp;&amp;amp; num &amp;lt; 5))
     {
          printf("Number Accepted");
     }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Important Observation&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Not (con1 AND con 2) &amp;nbsp;= Not (con1) OR&amp;nbsp;&lt;/b&gt;&lt;b&gt;Not (con2)&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;In this example&lt;/b&gt;&lt;br /&gt;
&lt;div style="background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); color: #333333; display: inline-block; font-size: 15px; line-height: 20px; padding-left: 30px; padding: 10px; width: 80%;"&gt;
&lt;b&gt;!(num &amp;gt; 3 &amp;amp;&amp;amp; num &amp;lt;5)&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;= !(num &amp;nbsp;&amp;gt; 3) || !(num &amp;lt; 5 )&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;= (num &amp;lt; 3) OR (num &amp;nbsp;&amp;gt; 5) &amp;nbsp; ........... &amp;nbsp; &amp;nbsp;(This is the result of OR example)&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;We can compare the 2 results to prove it:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1DtNmitzwvP8UBXCjd0Dy0tfe4e5dik4ojHqKebqsELQBCxUAs1HbZXaQTdYvu1YDkPWD1ZAavW7RhooA5soiJ8I2Ha6G7ecs_QMK0zzBbocT9DwI-CjPDGsLDYtPmdwmMQ5vptcyTBM/s1600/and+res.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1DtNmitzwvP8UBXCjd0Dy0tfe4e5dik4ojHqKebqsELQBCxUAs1HbZXaQTdYvu1YDkPWD1ZAavW7RhooA5soiJ8I2Ha6G7ecs_QMK0zzBbocT9DwI-CjPDGsLDYtPmdwmMQ5vptcyTBM/s1600/and+res.bmp" /&gt;&lt;/a&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhv6suks2f9JYWhwVLvjNMwQmqmKHZ_nsd4tQA-vEbBHH-T9WYPV02qCJoOf-6Lfjc0G7DSzLwaW7m41Iv7USfXX9YIhbV7kIHDVO1r720hvtabp9Xt5v2gSdpxYPX9azyXt6wRbfbjAM/s1600/not+res.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhv6suks2f9JYWhwVLvjNMwQmqmKHZ_nsd4tQA-vEbBHH-T9WYPV02qCJoOf-6Lfjc0G7DSzLwaW7m41Iv7USfXX9YIhbV7kIHDVO1r720hvtabp9Xt5v2gSdpxYPX9azyXt6wRbfbjAM/s1600/not+res.bmp" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I have tried my best to explain multiple conditions with Boolean operators, but if you still have any doubts or suggestions feel free to comment.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: 15px; line-height: 20px;"&gt;&lt;b&gt;&lt;a href="http://mycodedotc.blogspot.in/2012/10/chapter-11-adding-conditions-using-if.html"&gt;Previous Post&lt;/a&gt; &amp;nbsp; &amp;nbsp; &lt;a href="http://mycodedotc.blogspot.in/2012/11/chapter-13-nested-conditions-using.html"&gt;Next Post&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description><link>http://mycodedotc.blogspot.com/2012/10/chapter-12-adding-conditions-using-if.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWBNVqwqWKJQie-VmePkgspgaTuZoAdS9FegMzdufOiQEsbi4pe5mNIs5OXiq8RBqVpofK2dGga3hwqWCXLs-FeeoDl-15O_twUdfUigJWlhhEar7YklyryDuebAd0Xy7A-uRJYiu6jws/s72-c/main.bmp" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-7954470212850526825</guid><pubDate>Thu, 04 Oct 2012 18:06:00 +0000</pubDate><atom:updated>2013-09-02T19:15:23.796+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Archive</category><title>Chapter 11 - Adding Conditions (Using If statement) [Part 1 of 3]</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shCore.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shBrushCpp.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;script type="text/javascript"&gt;
  SyntaxHighlighter.config.clipboardSwf = 'https://dl.dropbox.com/u/102425073/code/scripts/clipboard.swf';
  SyntaxHighlighter.all();
 
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
&lt;/script&gt;
&lt;br /&gt;
From this tutorial&amp;nbsp;on wards everything you learn will exponentially add up to your capability of programming. Hence make sure what ever you learn here, learn it correctly.&lt;br /&gt;
&lt;br /&gt;
To be a good programmer one has to be confident with the basics. So go through each and every concept again and again till you are can confidently use them when you need them.&lt;br /&gt;
&lt;br /&gt;
Also try to put to use all that you have learned so far, it will always help you fresh with what you have learned.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So lets start with knowing how conditions work&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;Knowing the Syntax&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div style="background-color: white;"&gt;
&lt;div style="text-align: center;"&gt;
&lt;div style="background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); color: #333333; display: inline-block; font-family: Verdana, sans-serif; font-size: 15px; line-height: 20px; padding: 20px; width: 25%;"&gt;
&lt;div style="text-align: left;"&gt;
&lt;h3 style="text-align: left;"&gt;
&lt;b&gt;if (condition)&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;b&gt;&lt;b&gt;{&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/h3&gt;
&lt;h3 style="text-align: left;"&gt;
&lt;b&gt;&lt;b&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;b&gt;&lt;b&gt;&amp;nbsp; ...........&lt;/b&gt;&lt;/b&gt;&lt;/h3&gt;
&lt;h3 style="text-align: left;"&gt;
&lt;b&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/b&gt;&lt;b&gt;&amp;nbsp; ...........&amp;nbsp;&lt;/b&gt;&lt;/h3&gt;
&lt;h3 style="text-align: left;"&gt;
&lt;b&gt;}&lt;/b&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;b&gt;
&lt;/b&gt;
&lt;b&gt;


&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br class="Apple-interchange-newline" /&gt;
&lt;br /&gt;
Lets understand this using simple examples in english&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;If your percentage is above 40 you pass&lt;/li&gt;
&lt;li&gt;If your age is above 18 you can vote&lt;/li&gt;
&lt;li&gt;If you ran a distance 42 km you have completed the marathon&lt;/li&gt;
&lt;li&gt;If a number is divisible by 2 it is even&lt;/li&gt;
&lt;li&gt;If you press 'y' you can proceed&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Now that we have our examples the first thing we are going to do is break them into 2 parts. First the condition and the the action.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div align="center"&gt;
&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;"&gt;
 &lt;tbody&gt;
&lt;tr&gt;
  &lt;td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 2.2in;" valign="top" width="211"&gt;&lt;div class="MsoNormal"&gt;
&lt;b&gt;Condition&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 2.5in;" valign="top" width="240"&gt;&lt;div class="MsoNormal"&gt;
&lt;b&gt;Action&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 2.2in;" valign="top" width="211"&gt;&lt;div class="MsoNormal"&gt;
Percentage greater than 40&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 2.5in;" valign="top" width="240"&gt;&lt;div class="MsoNormal"&gt;
You pass&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 2.2in;" valign="top" width="211"&gt;&lt;div class="MsoNormal"&gt;
Age is above &amp;nbsp;18&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 2.5in;" valign="top" width="240"&gt;&lt;div class="MsoNormal"&gt;
You can vote&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 2.2in;" valign="top" width="211"&gt;&lt;div class="MsoNormal"&gt;
Ran a distance of 42 km&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 2.5in;" valign="top" width="240"&gt;&lt;div class="MsoNormal"&gt;
You completed the marathon&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 2.2in;" valign="top" width="211"&gt;&lt;div class="MsoNormal"&gt;
Number divisible by 2&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 2.5in;" valign="top" width="240"&gt;&lt;div class="MsoNormal"&gt;
It is even&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 2.2in;" valign="top" width="211"&gt;&lt;div class="MsoNormal"&gt;
You press ‘y’&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 2.5in;" valign="top" width="240"&gt;&lt;div class="MsoNormal"&gt;
You can proceed&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we know how to break the statements into&amp;nbsp;conditions and actions the next part is to know how to implement comparisons&amp;nbsp;progmatically.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div align="center"&gt;
&lt;div align="center"&gt;
&lt;table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="background: #F9F9F9; border-collapse: collapse; mso-padding-alt: 0in 0in 0in 0in; mso-yfti-tbllook: 1184; width: 494px;"&gt;
 &lt;tbody&gt;
&lt;tr style="height: 26.4pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;"&gt;
  &lt;td rowspan="2" style="background: #F2F2F2; border: solid #AAAAAA 1.0pt; height: 26.4pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 213.9pt;" width="285"&gt;&lt;div align="center" class="MsoNormal" style="line-height: 14.4pt; text-align: center;"&gt;
&lt;b&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Operator&amp;nbsp;name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td rowspan="2" style="background: #F2F2F2; border-left: none; border: solid #AAAAAA 1.0pt; height: 26.4pt; mso-border-left-alt: solid #AAAAAA 1.0pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 156.4pt;" width="209"&gt;&lt;div align="center" class="MsoNormal" style="line-height: 14.4pt; text-align: center;"&gt;
&lt;b&gt;&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;Syntax&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="height: 26.4pt; padding: 0in 0in 0in 0in; width: .3pt;" width="0"&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="height: 3.0pt; mso-yfti-irow: 1;"&gt;
  &lt;td style="height: 3.0pt; padding: 0in 0in 0in 0in; width: .3pt;" width="0"&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="height: 11.0pt; mso-yfti-irow: 2;"&gt;
  &lt;td style="border-top: none; border: solid #AAAAAA 1.0pt; height: 11.0pt; mso-border-top-alt: solid #AAAAAA 1.0pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 213.9pt;" width="285"&gt;&lt;div class="MsoNormal" style="line-height: 14.4pt;"&gt;
&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;Equal
  to&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; height: 11.0pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 156.4pt;" width="209"&gt;&lt;div align="center" class="MsoNormal" style="line-height: 14.4pt; text-align: center;"&gt;
&lt;span courier="" en-us="en-us" mso-ansi-language:en-us="mso-ansi-language:en-us" mso-bidi-font-family:="mso-bidi-font-family:" mso-bidi-language:ar-sa="mso-bidi-language:ar-sa" mso-fareast-font-family:="mso-fareast-font-family:" mso-fareast-language:="" new="" roman="roman" serif="serif" style="font-family: &amp;quot;; font-size: 12.0pt; line-height: 115%;" times=""&gt;&lt;b&gt;a&amp;nbsp;==&amp;nbsp;b&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="height: 11.0pt; padding: 0in 0in 0in 0in; width: .3pt;" width="0"&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="height: 12.35pt; mso-yfti-irow: 3;"&gt;
  &lt;td style="border-top: none; border: solid #AAAAAA 1.0pt; height: 12.35pt; mso-border-top-alt: solid #AAAAAA 1.0pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 213.9pt;" width="285"&gt;&lt;div class="MsoNormal" style="line-height: 14.4pt;"&gt;
&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;Not
  equal to&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; height: 12.35pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 156.4pt;" width="209"&gt;&lt;div align="center" class="MsoNormal" style="line-height: 14.4pt; text-align: center;"&gt;
&lt;span courier="" en-us="en-us" mso-ansi-language:en-us="mso-ansi-language:en-us" mso-bidi-font-family:="mso-bidi-font-family:" mso-bidi-language:ar-sa="mso-bidi-language:ar-sa" mso-fareast-font-family:="mso-fareast-font-family:" mso-fareast-language:="" new="" roman="roman" serif="serif" style="font-family: &amp;quot;; font-size: 12.0pt; line-height: 115%;" times=""&gt;&lt;b&gt;a&amp;nbsp;!=&amp;nbsp;b&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="height: 12.35pt; padding: 0in 0in 0in 0in; width: .3pt;" width="0"&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid #AAAAAA 1.0pt; mso-border-top-alt: solid #AAAAAA 1.0pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 213.9pt;" width="285"&gt;&lt;div class="MsoNormal" style="line-height: 14.4pt;"&gt;
&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;Greater
  than&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 156.4pt;" width="209"&gt;&lt;div align="center" class="MsoNormal" style="line-height: 14.4pt; text-align: center;"&gt;
&lt;span courier="" en-us="en-us" mso-ansi-language:en-us="mso-ansi-language:en-us" mso-bidi-font-family:="mso-bidi-font-family:" mso-bidi-language:ar-sa="mso-bidi-language:ar-sa" mso-fareast-font-family:="mso-fareast-font-family:" mso-fareast-language:="" new="" roman="roman" serif="serif" style="font-family: &amp;quot;; font-size: 12.0pt; line-height: 115%;" times=""&gt;&lt;b&gt;a&amp;nbsp;&amp;gt;&amp;nbsp;b&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="padding: 0in 0in 0in 0in; width: .3pt;" width="0"&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid #AAAAAA 1.0pt; mso-border-top-alt: solid #AAAAAA 1.0pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 213.9pt;" width="285"&gt;&lt;div class="MsoNormal" style="line-height: 14.4pt;"&gt;
&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;Less
  than&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 156.4pt;" width="209"&gt;&lt;div align="center" class="MsoNormal" style="line-height: 14.4pt; text-align: center;"&gt;
&lt;span courier="" en-us="en-us" mso-ansi-language:en-us="mso-ansi-language:en-us" mso-bidi-font-family:="mso-bidi-font-family:" mso-bidi-language:ar-sa="mso-bidi-language:ar-sa" mso-fareast-font-family:="mso-fareast-font-family:" mso-fareast-language:="" new="" roman="roman" serif="serif" style="font-family: &amp;quot;; font-size: 12.0pt; line-height: 115%;" times=""&gt;&lt;b&gt;a&amp;nbsp;&amp;lt;&amp;nbsp;b&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="padding: 0in 0in 0in 0in; width: .3pt;" width="0"&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="height: 11.45pt; mso-yfti-irow: 6;"&gt;
  &lt;td style="border-top: none; border: solid #AAAAAA 1.0pt; height: 11.45pt; mso-border-top-alt: solid #AAAAAA 1.0pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 213.9pt;" width="285"&gt;&lt;div class="MsoNormal" style="line-height: 14.4pt;"&gt;
&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;Greater
  than or equal to&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; height: 11.45pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 156.4pt;" width="209"&gt;&lt;div align="center" class="MsoNormal" style="line-height: 14.4pt; text-align: center;"&gt;
&lt;span courier="" en-us="en-us" mso-ansi-language:en-us="mso-ansi-language:en-us" mso-bidi-font-family:="mso-bidi-font-family:" mso-bidi-language:ar-sa="mso-bidi-language:ar-sa" mso-fareast-font-family:="mso-fareast-font-family:" mso-fareast-language:="" new="" roman="roman" serif="serif" style="font-family: &amp;quot;; font-size: 12.0pt; line-height: 115%;" times=""&gt;&lt;b&gt;a&amp;nbsp;&amp;gt;=&amp;nbsp;b&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="height: 11.45pt; padding: 0in 0in 0in 0in; width: .3pt;" width="0"&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr style="height: 12.35pt; mso-yfti-irow: 7; mso-yfti-lastrow: yes;"&gt;
  &lt;td style="border-top: none; border: solid #AAAAAA 1.0pt; height: 12.35pt; mso-border-top-alt: solid #AAAAAA 1.0pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 213.9pt;" width="285"&gt;&lt;div class="MsoNormal" style="line-height: 14.4pt;"&gt;
&lt;span style="font-family: &amp;quot;Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 10.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;Less
  than or equal to&lt;/span&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid #AAAAAA 1.0pt; border-left: none; border-right: solid #AAAAAA 1.0pt; border-top: none; height: 12.35pt; padding: 2.4pt 2.4pt 2.4pt 2.4pt; width: 156.4pt;" width="209"&gt;&lt;div align="center" class="MsoNormal" style="line-height: 14.4pt; text-align: center;"&gt;
&lt;b&gt;&lt;span courier="" en-us="en-us" mso-ansi-language:en-us="mso-ansi-language:en-us" mso-bidi-font-family:="mso-bidi-font-family:" mso-bidi-language:ar-sa="mso-bidi-language:ar-sa" mso-fareast-font-family:="mso-fareast-font-family:" mso-fareast-language:="" new="" roman="roman" serif="serif" style="font-family: &amp;quot;; font-size: 12.0pt; line-height: 115%;" times=""&gt;a&amp;nbsp;&amp;lt;=&amp;nbsp;b&lt;/span&gt;&lt;!--EndFragment--&gt;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="height: 12.35pt; padding: 0in 0in 0in 0in; width: .3pt;" width="0"&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;b&gt;Note: '==' stands for comparison and '=' stands for&amp;nbsp;assignment.&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;b&gt;Example :- &amp;nbsp; &amp;nbsp;a == b compare a is equal to b, where as&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a = &amp;nbsp;b means copy value of b in a.&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
It is important that you learn to &amp;nbsp;make this distinction early on as a misinterpretation leads to a lot of errors.&lt;/div&gt;
&lt;u&gt;Also every comparison operator&amp;nbsp;returns&amp;nbsp;an integer value 0 or 1. 1 for true and 0 for false.&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
I have written a small program to illustrate this concept&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 4th October 2012  
 Title : Program to illustrate the truth values of comparison operation 
*/  

#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

void main()
 {
  //using two values to compare
  int a=5, b=10;
  int result=0;

  clrscr();

  //comparison returns 0 when false
  result = a == b;
  printf("The result of comparison when false: %d",result);

  //comparison returns 0 when true
  result = a &amp;lt; b;
  printf("\nThe result of comparison when true: %d",result);

  getch();
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;How the If statement works&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Every If statement requires a condition, and the code written in the if block is executed only of the&amp;nbsp;comparison&amp;nbsp;returns true, i.e 1.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://www.byterevel.com/wp-content/uploads/2011/07/ifelse.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://www.byterevel.com/wp-content/uploads/2011/07/ifelse.png" width="268" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
This program is an simple example to show how "If statement" works.&amp;nbsp;To illustrate the point i have written a complete code for only one of the five examples discussed above.&amp;nbsp;Below this code are code block you can replace to implement other examples.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 4th October 2012  
 Title : Program to check if one has passed
*/  

#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

void main()
 {

  int marks=0, pass_val=40;

  clrscr();

  //prompt the user to enter his percentage out of 100
  printf("Enter your marks (out of 100):");
  scanf("%d",&amp;amp;marks);

  //compare the result to the passing value
  if(marks &amp;gt;= pass_val)
   {
    printf("\n+---------------------+");
    printf("\n|                     |");
    printf("\n| You passed the exam |");
    printf("\n|                     |");
    printf("\n+---------------------+");
   }

  getch();
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;The code block for other examples are :&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt; 
 if(age &amp;gt;= 18)
 {
  printf("You can vote"); 
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt; 
 if(run_distance &amp;gt; 42)
 {
  printf("You completed the marathon"); 
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt; 
 if(number%2 == 0)
 {
  printf("The number is even"); 
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt; 
 if(key == 'y')
 {
  printf("You can proceed"); 
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a three part tutorial, the other two will each extend the concepts you have learned in the previous part.&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: 15px; line-height: 20px;"&gt;&lt;b&gt;&lt;a href="http://mycodedotc.blogspot.in/2012/09/chapter-10-taking-input-from-user.html"&gt;Previous Post&lt;/a&gt; &amp;nbsp; &amp;nbsp; &lt;a href="http://mycodedotc.blogspot.in/2012/10/chapter-12-adding-conditions-using-if.html"&gt;Next Post&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2012/10/chapter-11-adding-conditions-using-if.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-1720304147941839704</guid><pubDate>Sun, 23 Sep 2012 16:39:00 +0000</pubDate><atom:updated>2013-08-24T20:20:13.089+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Archive</category><title>Chapter 10 - Taking input from User</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Until&amp;nbsp;now all you did was assigned values to the variables and printed them.&lt;br /&gt;
&lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shCore.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shBrushCpp.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;script type="text/javascript"&gt;
  SyntaxHighlighter.config.clipboardSwf = 'https://dl.dropbox.com/u/102425073/code/scripts/clipboard.swf';
  SyntaxHighlighter.all();
 &lt;/script&gt;
&lt;br /&gt;
In this tutorial we will learn to take input from the users. The syntax for scanning an input is similar to that of printf() function. Both&lt;b&gt; pritf() and scanf() &lt;/b&gt;functions are &lt;b&gt;defined &lt;/b&gt;withing &lt;b&gt;stdio.h header&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
The programs below will work in the following steps:&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;We will first declare and&amp;nbsp;initialize a variable&amp;nbsp;.&lt;/li&gt;
&lt;li&gt;Take a value from the user and store it in our variable (this step will re initialize the value of that variable).&lt;/li&gt;
&lt;li&gt;Print the value stored in that variable.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In order to understand how each data type scans value (and also for future references) i have written 3 separate codes for each of the data types we have learned so far.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="background-color: #eeeeee; border-color: #999999; border-style: solid; border-width: 1px; display: inline-block; padding: 3px; width: 50%;"&gt;
Note that the execution of the program stops when it encounters a scanf() function and does not proceed until the user enters some input&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif; font-size: 16pt;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif; font-size: 16pt;"&gt;scanf() for 'int' data type:&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
In the code below we will declare a number; say age then ask the user to enter his age.&lt;br /&gt;
To make the code interesting we will subtract his age from 2012 and print &lt;b&gt;"You were born in ..."&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 23rd September 2012  
 Title : Calculates the Year of Birth 
*/  

#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

void main()
 {
  int age = 0,yob = 0;  // initialized the variabe to avoid errors

  clrscr();

  //prompting the user to enter age
  printf("Please enter your age: ");

  //scanf takes the input and stores it in variable age
  scanf("%d",&amp;amp;age);

  //calculate year of brith
  yob = 2012 - age;

  //printing the Year of Birth
  printf("\nYou were born in: %d", yob);

  getch();
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;div&gt;
As you can see, the scanf() function has a similar syntax, the only difference is that you have to &lt;b&gt;add '&amp;amp;' to prefix to the variable name.&lt;/b&gt;&amp;nbsp;Like everything else this also has meaning. After we are done dealing with all the three data types i will explain the reason&amp;nbsp;behind&amp;nbsp;it.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now lets check the float data type.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif; font-size: 16pt;"&gt;scanf() for float data type:&amp;nbsp;&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
In this example we will write a code to convert distance in kilometers to miles. First we will declare a variable say distance. Scan the value from the user and store it in distance. then we will apply the following conversion to convert kilometers into miles.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="background-color: #eeeeee; border-style: solid; border-width: 1px; padding: 3px;"&gt;&lt;span style="border-color: #999999; font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"&gt;1 Kilometer &amp;nbsp;= &amp;nbsp;0.621371 Miles&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 23rd September 2012  
 Title : Converts distance from Km to Miles 
*/  

#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

void main()
 {
  float km = 0.0, miles = 0.0;  // initialized the variabe to avoid errors

  clrscr();

  //prompting the user to enter distance
  printf("Please enter distance in kilmoeters: ");

  //scanf takes the input and stores it in variable km
  scanf("%f",&amp;amp;km);

  //calculate distance in miles
  miles = km * 0.621371;

  //printing the distance in miles
  printf("\nThe distance is miles is: %.2f", miles);

  getch();
 }
&lt;/pre&gt;
&lt;br /&gt;
Nothing special to mention, the method to scan a float is similar to that of int and the &lt;b&gt;'.2' between % and f is to display value only up to 2 decimal places &lt;/b&gt;. So 1 more data type to go before the explanation for '&amp;amp;' .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif; font-size: 16pt;"&gt;scanf() for char data type:&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
All i could think of is a code that takes a character input and prints the ACSII value of it. We all have&amp;nbsp;implemented&amp;nbsp;this in the previous chapter, the only change here being, user gets to enter the character.&lt;/div&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 23rd September 2012  
 Title : Gives the ASCII code of the key entered 
*/  

#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

void main()
 {
  char ch = 'a'; // initialized the variabe to avoid errors

  clrscr();

  //prompting the user to enter a digit
  printf("Enter a digit: ");

  //scanf takes the input and stores it in variable ch
  scanf("%c",&amp;amp;ch);

  //printing the ACSCII value
  printf("\nThe ASCII value is: %d", ch);

  getch();
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;The mystery behind '&amp;amp;'&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I had said this in the first chapter that data (in computer) is stored in the memory and has an address associated with it.&lt;b&gt;&amp;nbsp;Writing &amp;amp; as prefix to variable name (i.e. &amp;amp;age, &amp;amp;ch, etc.) gives the address of the variable.&lt;/b&gt;&amp;nbsp;When you declare a variable the compiler&amp;nbsp;assigns it an address in main memory and hence when you take a value from the user you tell scanf to store it in the address which is given by &amp;amp; followed by variable name.&lt;br /&gt;
&lt;br /&gt;
If you are unable to understand what i have explained or if you can provide a better explanation please comment and i will make the necessary changes.&lt;br /&gt;
&lt;br /&gt;
Now that you have learned to take input from the users, there are a lot of things that you can do. Try out the things listed out in Activities&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: x-large;"&gt;Activities&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;&amp;nbsp;Try to implement all the programs given in the previous chapters, but make use of scanf to set the values of the variables used.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Try to write a program that takes the marks of 5 subjects(store it in 5 variables) and the total marks (out of) from the user and calculates his/her percentage.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&amp;nbsp;By doing this you will be able to write an actual program, one which takes input from users, processes it and produces results.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: 15px; line-height: 20px;"&gt;&lt;b&gt;&lt;a href="http://mycodedotc.blogspot.in/2012/09/chapter-9-char-data-type.html"&gt;Previous Post&lt;/a&gt; &amp;nbsp; &amp;nbsp; &lt;a href="http://mycodedotc.blogspot.in/2012/10/chapter-11-adding-conditions-using-if.html"&gt;Next Post&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2012/09/chapter-10-taking-input-from-user.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-7232848555348978164</guid><pubDate>Sun, 16 Sep 2012 17:32:00 +0000</pubDate><atom:updated>2013-08-26T19:30:28.642+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Archive</category><title>Chapter 9 - The Char Data Type</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shCore.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shBrushCpp.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;script type="text/javascript"&gt;
  SyntaxHighlighter.config.clipboardSwf = 'https://dl.dropbox.com/u/102425073/code/scripts/clipboard.swf';
  SyntaxHighlighter.all();
 &lt;/script&gt;
In the previous chapters we have learnt 2 Data Types, &lt;a href="http://mycodedotc.blogspot.in/2012/08/chapter-4-implementing-int.html" target="_blank"&gt;int&lt;/a&gt; and &lt;a href="http://mycodedotc.blogspot.in/2012/09/chapter-5-implementing-float.html" target="_blank"&gt;float&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Now its time to learn how to use the char (character) Data Type.&lt;br /&gt;
This data type is slightly different from what we have learned so far. The knowledge of character will help u later to store and print names.&lt;br /&gt;
By the end of this post i guarantee you that you will know all the basics of a character data type and capable of using it in your own program.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;How do we use it ?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
In our first code we will simply assign a value to a character data type and the print what we have stored.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 16th September 2012  
 Title : implementing char data type
*/  

#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

void main()
 {
  char c = 'a';

  clrscr();

  //printing the character
  printf("The character is: %c", c);

  getch();
 }
&lt;/pre&gt;
&lt;br /&gt;
It is evident from the code that you can't simply&amp;nbsp;assign&amp;nbsp;a&amp;nbsp;character&amp;nbsp;directly to a char variable.&lt;br /&gt;
&lt;div style="text-align: left;"&gt;
&lt;/div&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;b&gt;The value must be enclosed in a ' ' (single quotes)&lt;/b&gt;.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Only one character can be assigned to a char variable. &lt;/b&gt;So dont &amp;nbsp;try something like this c = 'name' . This will return an error. Be patient, we will deal with full words later.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style="font-size: large;"&gt;More on Character&lt;/span&gt;&lt;br /&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
You might be knowing that computer deals with only digital data ( i.e 0's and 1's ) which are represented collectively as numbers. So how does it store a character.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
To answer this question we must know that every character has a &lt;a href="http://en.wikipedia.org/wiki/ASCII" target="_blank"&gt;ASCII &lt;/a&gt;value assigned to it. The complete ASCII table is shown below.&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCJqLBRN6QmNZSDubMiz6tskwboS_Dmcf_hDuI4Lp2ZBjt0_d5orcVLKwgntrj3VvfFvZjNyU4AnJJnv9owsI4EeKNxkrpqP1nfi6EprJNppVB_LbuBaQbs4gVYZYdx0mXd64J88UnkYY/s1600/ASCII_0_127.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="464" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCJqLBRN6QmNZSDubMiz6tskwboS_Dmcf_hDuI4Lp2ZBjt0_d5orcVLKwgntrj3VvfFvZjNyU4AnJJnv9owsI4EeKNxkrpqP1nfi6EprJNppVB_LbuBaQbs4gVYZYdx0mXd64J88UnkYY/s640/ASCII_0_127.jpg" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
So whenever you press a key on your keyboard the computer records them as these values, and not as characters.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
This leads us to our next question&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;span style="font-size: large;"&gt;How do we check the ACSII value of a char ?&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
The code below will do just that.&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 16th September 2012  
 Title : implementing char data type 
    by assigning ascii value
*/  

#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

void main()
 {
  char c = 65;

  clrscr();

  //printing the character
  printf("The character is: %c", c);
  printf("\nIts ASCII value is: %d", c);

  getch();
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
As you must have noticed you can assign an ASCII value to a character just as you assign a value to an integer.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;b&gt;Note : The value should be in the range of 0 - 127 &lt;/b&gt;, or else you will be assigning an illegal value&amp;nbsp;which&amp;nbsp;will lead to an error in your code.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;span style="font-size: large;"&gt;Playing with the ASCII values&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Now that you know that ascii values can be assigned like integers lets try to experiment with the logic. What i have done in the code below is incremented the ASCII value of char by 1.&lt;/div&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 16th September 2012  
 Title : implementing char data type 
*/  

#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

void main()
 {
  char c = 'a';

  clrscr();

  //printing the character
  printf("The character is: %c", c);
  printf("\nIts ASCII value is: %d", c);

  //increment the vale of c
  c = c + 1;
  printf("\n\nThe new value is : %c",c);
  printf("\nThe new ACSII value is: %d",c);

  getch();
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
You can try incrementing it by 5 or 10, or multiplying it by 2. But make sure the value falls within the range of 0 - 127.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;span style="font-size: large;"&gt;The Master code&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;span style="font-size: large;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
What i have done in the code below is combined all the concepts we have learned in this tutorial so far and made a simple program. Try implementing it yourself and also make some changes to experiment with the results.&lt;/div&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 16th September 2012  
 Title : implementing char data type 
*/  

#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;

void main()
 {
  char c = 'a';

  clrscr();

  //initial value of c
  printf("The value is: %c",c);
  printf("\nIts ASCII value is: %d",c);

  //assinging a value to char
  c = '%';
  printf("\n\nThe new value is: %c",c);
  printf("\nIts new ASCII value is: %d",c);

  //assigning an ASCII value to char
  c = 67;
  printf("\n\nThe latest value is: %c",c);
  printf("\nIts latest ASCII value is: %d",c);


  getch();
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: 15px; line-height: 20px;"&gt;&lt;b&gt;&lt;a href="http://mycodedotc.blogspot.in/2012/09/chapter-8-modulus-operator.html"&gt;Previous Post&lt;/a&gt; &amp;nbsp; &amp;nbsp; &lt;a href="http://mycodedotc.blogspot.in/2012/09/chapter-10-taking-input-from-user.html"&gt;Next Post&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2012/09/chapter-9-char-data-type.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCJqLBRN6QmNZSDubMiz6tskwboS_Dmcf_hDuI4Lp2ZBjt0_d5orcVLKwgntrj3VvfFvZjNyU4AnJJnv9owsI4EeKNxkrpqP1nfi6EprJNppVB_LbuBaQbs4gVYZYdx0mXd64J88UnkYY/s72-c/ASCII_0_127.jpg" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-6758550402677039753</guid><pubDate>Sun, 16 Sep 2012 10:15:00 +0000</pubDate><atom:updated>2013-08-24T20:19:44.575+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Archive</category><title>Chapter 8 - The Modulus Operator</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
In the &lt;a href="http://mycodedotc.blogspot.in/2012/09/chapter-7-writing-our-own-program.html" target="_blank"&gt;previous chapters&lt;/a&gt; i purposely skipped one important math operator. Its &amp;nbsp;called the&amp;nbsp;Modulus or mod operator ( % ). Explaining this in the previous chapters would add to the&amp;nbsp;confusion&amp;nbsp;and hence i am writing a mini post for this special operator. In the time to come you will be using this quite often in &amp;nbsp;solving certain problems.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;What does this Operator do ?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This operator &lt;b&gt;returns the remainder of division&lt;/b&gt;. To illustrate its working look at the image below&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwvpFe-NFV4FgpJDUD-DNP0bm1ekdikPOAN6aJKROpJtPSq00ROyMc2pExZKNau2LEDntsHORX-kHcjS_2aXXBn-kRrhqVwsAct5fm1KMN0PKt_Y2upwkwqBa09PqRXyO1ST48tGJxVzk/s1600/remainder1.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="167" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwvpFe-NFV4FgpJDUD-DNP0bm1ekdikPOAN6aJKROpJtPSq00ROyMc2pExZKNau2LEDntsHORX-kHcjS_2aXXBn-kRrhqVwsAct5fm1KMN0PKt_Y2upwkwqBa09PqRXyO1ST48tGJxVzk/s320/remainder1.gif" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&amp;nbsp; Here &amp;nbsp;&lt;b&gt;7 % 2 &lt;/b&gt;will give an output of 1.&lt;br /&gt;
&lt;br /&gt;
Similarly&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;b&gt;4 % 5 = 4&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;12 % 3 = 0&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;54 % 4 = 2&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;Significance of this operator&lt;/span&gt;&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;b&gt;Look and the results in each case and notice that the results ( i.e. the remainder is always less than divisor )&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Also that if the divisor ( 3 in example 2) divides the&amp;nbsp;dividend&amp;nbsp;( 12 ) then the output will be 0&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-size: large;"&gt;Where can you use this operator&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;You can use this operator to determine whether a number (divisor) completely divides other number (dividend).&lt;/li&gt;
&lt;li&gt;Extending this logic we can&amp;nbsp;determine&amp;nbsp;if a number is&lt;b&gt; odd or even by using 2 as divisor.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;You can also use this operator to reduce a number to some number less than the divisor&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;Example&lt;/b&gt;: &amp;nbsp; Consider large numbers like 12344. &amp;nbsp;Using 12344 % 5 you can reduce this number to 4. Similarly you can reduce 845 can be reduced to 0.&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This may not seem&amp;nbsp;useful&amp;nbsp;now but you may need to use this to solve certain problems.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-size: x-large;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-size: x-large;"&gt;Activities:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;I have purposely skipped the code. So your first task is to write a simple code printing the result.&lt;/li&gt;
&lt;li&gt;Adjust the values of operand 1 and operand 2 two &amp;nbsp;and examine the result.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: 15px; line-height: 20px;"&gt;&lt;b&gt;&lt;a href="http://mycodedotc.blogspot.in/2012/09/chapter-7-writing-our-own-program.html"&gt;Previous Post&lt;/a&gt; &amp;nbsp; &amp;nbsp; &lt;a href="http://mycodedotc.blogspot.in/2012/09/chapter-9-char-data-type.html"&gt;Next Post&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2012/09/chapter-8-modulus-operator.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwvpFe-NFV4FgpJDUD-DNP0bm1ekdikPOAN6aJKROpJtPSq00ROyMc2pExZKNau2LEDntsHORX-kHcjS_2aXXBn-kRrhqVwsAct5fm1KMN0PKt_Y2upwkwqBa09PqRXyO1ST48tGJxVzk/s72-c/remainder1.gif" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-7194156508565001923</guid><pubDate>Wed, 12 Sep 2012 18:09:00 +0000</pubDate><atom:updated>2013-08-24T20:19:31.935+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Archive</category><title>Chapter 7 - Writing our own program</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shCore.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shBrushCpp.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;script type="text/javascript"&gt;
  SyntaxHighlighter.config.clipboardSwf = 'https://dl.dropbox.com/u/102425073/code/scripts/clipboard.swf';
  SyntaxHighlighter.all();
 &lt;/script&gt;

&lt;br /&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Now that we know quite a bit about programming lets try to mend some problems into our programs.

&lt;br /&gt;
You all know that how using integer values to store (result of) a float neglects the decimal part. We can make use of this logic to separate the decimal part from the whole number.&lt;br /&gt;
&lt;br /&gt;
What i mean to say is&lt;b&gt; if you are given a number like 3.4563&lt;/b&gt; write a program to separate the decimal part. So &lt;b&gt;the program should only print 0.4563&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
For those who cant figure out the solution can use the code below.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 12th September 2012  
 Title : implementing a complex equation
 with short hand
*/  

#include&amp;lt;conio.h&amp;gt;
#include&amp;lt;stdio.h&amp;gt;

void main()
 {
  float num=34.3345,result;
  int temp;

  clrscr();
  //our logic
  temp = num; // this will store the number without the decimal part
  result = num - temp; // this will subtract non decimal part

  printf("The decimal part is : %f",result);
  getch();
 }
&lt;/pre&gt;
&lt;br /&gt;
I know you might be wondering y only one program. the thing is i got this idea for a simple program and wanted to share it. Without the knowledge of comparisons and loops there not a lot different that can be done, hence i have reserved a lot of fun practice programs after we learn a little more on programming. &lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: 15px; line-height: 20px;"&gt;&lt;b&gt;&lt;a href="http://mycodedotc.blogspot.in/2012/09/chapter-6-mathematics-operationspart-1.html"&gt;Previous Post&lt;/a&gt; &amp;nbsp; &amp;nbsp; &lt;a href="http://mycodedotc.blogspot.in/2012/09/chapter-8-modulus-operator.html"&gt;Next Post&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2012/09/chapter-7-writing-our-own-program.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-6371204180390493333</guid><pubDate>Wed, 12 Sep 2012 04:31:00 +0000</pubDate><atom:updated>2013-08-24T20:19:21.996+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Archive</category><title>Chapter 6 - Mathematical operations(part 1 of 2)</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shCore.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shBrushCpp.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;script type="text/javascript"&gt;
  SyntaxHighlighter.config.clipboardSwf = 'https://dl.dropbox.com/u/102425073/code/scripts/clipboard.swf';
  SyntaxHighlighter.all();
 &lt;/script&gt;
&lt;br /&gt;
By now you must be confident with writing a c program and fully capable of printing the output in any given format. This chapter will teach you to incorporate mathematical operations to your code. This chapter will cover simple operations like addition, subtraction, multiplication and division.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div&gt;
The reason&amp;nbsp;behind&amp;nbsp;not&amp;nbsp;dealing&amp;nbsp;with advanced mathematical operations is that these are in the form of functions and require a tutorial on functions. Moreover C has so many advanced mathematical functions that it cannot be covered in a single chapter. What i can do in later chapters is teach you the&amp;nbsp;method&amp;nbsp;to use these advanced operations in your program with one or two examples and thus you can make use of any mathematical operation you want as per your&amp;nbsp;requirement&amp;nbsp;using the same procedure.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So lets begin with the tutorial&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Lets start with variables &lt;b&gt;'a'&lt;/b&gt; and &lt;b&gt;'b'&lt;/b&gt; to store 2 values and we will be&amp;nbsp;applying&amp;nbsp;the 4 mathematical operations on them. To store the value of these &amp;nbsp;operations we will require a third variable called &lt;b&gt;'result'&lt;/b&gt;.&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;Any math operation will be of the form&lt;span style="font-size: large;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="font-size: large;"&gt;&lt;b&gt;result = a (operator) b&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="font-size: large;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
Consider the examples&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;div align="center"&gt;
&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;"&gt;
 &lt;tbody&gt;
&lt;tr style="height: 20.65pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;"&gt;
  &lt;td style="border: solid windowtext 1.0pt; height: 20.65pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 126.9pt;" valign="top" width="169"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"&gt;Addition:&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid windowtext 1.0pt; height: 20.65pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 99.0pt;" valign="top" width="132"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"&gt;4 = 3 + 1&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 126.9pt;" valign="top" width="169"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"&gt;Subtraction:&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 99.0pt;" valign="top" width="132"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"&gt;7 = 10 - 3&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 126.9pt;" valign="top" width="169"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"&gt;Multiplication:&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 99.0pt;" valign="top" width="132"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"&gt;42 = 7 * 6&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 126.9pt;" valign="top" width="169"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"&gt;Division&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 99.0pt;" valign="top" width="132"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: 'Times New Roman', serif; font-size: 13.5pt;"&gt;2.5 = 5 / 2&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
Note: In the first 3 examples the result of 2 integers will always be an integer but in case of division the result is a float (decimal) value. Hence when you write an expression in your program you need to determine what kind of variable is required to save the result in advance in order to avoid errors.&lt;br /&gt;
&lt;br /&gt;
Try to determine the &amp;nbsp;answers of the given examples&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;&lt;b&gt;3.5 + 1.4&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;1 - 0.56&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;0.0 * 1.0&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;5 / 3&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;b&gt;Answers:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;The result will be a float&lt;/li&gt;
&lt;li&gt;The result will be a float
&lt;/li&gt;
&lt;li&gt;Although the two numbers appear as decimal but they do not contain any fractional value ( just &lt;b&gt;.0&lt;/b&gt;) hence you can store the result in an int&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Although the 2 numbers are integers the division&amp;nbsp;operation&amp;nbsp;will&amp;nbsp;yield&amp;nbsp;a float hence the result will be a float&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
The program&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 12th September 2012  
 Title : prints the value of 4 mathematical operations
*/ 

#include&amp;lt;conio.h&amp;gt;
#include&amp;lt;stdio.h&amp;gt;

void main()
 {
  int a=23, b=12;
  int result;
  float divResult, fa=23.0, fb=12.0;

  clrscr();

  //adding two numbers
  result = a + b;
  printf("The result of addition is : %d", result);
  getch();

  //subtracting two numbers
  result = a - b;
  printf("\nThe result of subtraction is : %d", result);
  getch();

  //multiplying two numbers
  result = a * b;
  printf("\nThe result of multiplication is : %d", result);
  getch();

  //dividing two numbers
  divResult = fa / fb;
  printf("\nThe result of division is : %f", divResult);
  getch();
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;b&gt;Note: In the division operation to make the result accurate i have made use of float values as operands instead of integers ( although 23.0 and 12.0 are integers but they are stored in&amp;nbsp;float&amp;nbsp;data type) to get accurate results. If you replace them with integers a and b (instead of fa and fb) you will get a value of 1.0000 which is &amp;nbsp;incorrect.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
There is a short hand way to print the results of the mathematical equations, but i recommend you to make a&amp;nbsp;habit&amp;nbsp;to store the results in a variable, just a good programming practice and it avoids errors.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;printf("The result of addition is : %d", a + b);

printf("\nThe result of subtraction is : %d", a - b);

printf("\nThe result of multiplication is : %d", a * b);

printf("\nThe result of division is : %f", fa / fb);
&lt;/pre&gt;
&lt;br /&gt;
So the new code looks like this
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 12th September 2012  
 Title : prints the value of 4 mathematical operations 
 with short hand
*/  

#include&amp;lt;conio.h&amp;gt;
#include&amp;lt;stdio.h&amp;gt;

void main()
 {
  int a=23, b=12;
  int result;
  float divResult, fa=23.0, fb=12.0;
  
  clrscr();
  
  //adding two numbers
  printf("The result of addition is : %d", a + b);
  getch();
  
  //subtracting two numbers
  printf("\nThe result of subtraction is : %d", a - b);
  getch();
  
  //multiplying two numbers
  printf("\nThe result of multiplication is : %d", a * b);
  getch();
  
  //dividing two numbers
  printf("\nThe result of division is : %f", fa / fb);
  getch();
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
In this program we have simply used two operands , one operator and one value to store the result, but one can make use of more than one operators to form a mathematical equation.&lt;br /&gt;
&lt;br class="Apple-interchange-newline" /&gt;
&lt;br /&gt;
Consider the equation:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuiuVzCXx2LcnauhwfcZE6wzRDCEX29CUxYw41qpAX5BUkbwsHUtoABwNSZkno3Y6iqsxNG980OJn-IiTfyAcRggcsIonZKLkZ8yyNdp_dfcrmU-Ulu5wDeCvpoDxGACyLBz5OPz7d1ao/s1600/eqn.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuiuVzCXx2LcnauhwfcZE6wzRDCEX29CUxYw41qpAX5BUkbwsHUtoABwNSZkno3Y6iqsxNG980OJn-IiTfyAcRggcsIonZKLkZ8yyNdp_dfcrmU-Ulu5wDeCvpoDxGACyLBz5OPz7d1ao/s1600/eqn.bmp" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
In order to write this in our c program we will have to understand how this equation will get equated.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
If we break this equation we can see that there are two operators and we can write the 2 operators individually.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiD6pRDy01KYDSXX1wYOIQjgviCiAufK3Fbs1yxKg7jOlZtbubDFU-K0zgf9pEfnL3Hs7x6P6-ulv2C6k3FJAr0Z8dDdzpHBW2Bl2rIHLEUhphLODJstI_cg9XrpPnZF4zstalmK7S7gRI/s1600/eqn.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiD6pRDy01KYDSXX1wYOIQjgviCiAufK3Fbs1yxKg7jOlZtbubDFU-K0zgf9pEfnL3Hs7x6P6-ulv2C6k3FJAr0Z8dDdzpHBW2Bl2rIHLEUhphLODJstI_cg9XrpPnZF4zstalmK7S7gRI/s1600/eqn.bmp" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
So we can now combine them using&amp;nbsp;parenthesis&amp;nbsp;( )&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
So our equation becomes:&amp;nbsp;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;i&gt;&lt;b style="font-size: x-large;"&gt;result = a /(a+ b)&lt;/b&gt;&lt;span style="font-family: Times, Times New Roman, serif; font-size: large; font-weight: normal;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div style="text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Lets make use of this equation in our program and see how it works. In order to&amp;nbsp;determine if you have translated your equation correctly in the code you can solve it manually with some values and match them with the values returned by your code.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 12th September 2012  
 Title : implementing a complex equation
 with short hand
*/  

#include&amp;lt;conio.h&amp;gt;
#include&amp;lt;stdio.h&amp;gt;

void main()
 {
  float result, a=23.0, b=12.0;
  
  clrscr();
  
  result = a / (a +b);
  printf("The result of our equation is : %f",result);
  
  getch();
 }
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;Activities:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Try to change the data types for each mathematical operations and check the results&lt;/li&gt;
&lt;li&gt;Try to implement the following&amp;nbsp;equations&amp;nbsp;in &amp;nbsp;C&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk4y5TUQ66IIkKOHABzwY-4hSTbkiAPKNEiZ081E7n2b9U580BY8uIqXHo6ksighz-z3WmTAVwzPcxJQxqFaqrtC8jiULZtmcn20M_wlBqd-ggOrtkHS5qUQCX_i0SL3ulk1HEgEUBzOQ/s1600/eqn.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk4y5TUQ66IIkKOHABzwY-4hSTbkiAPKNEiZ081E7n2b9U580BY8uIqXHo6ksighz-z3WmTAVwzPcxJQxqFaqrtC8jiULZtmcn20M_wlBqd-ggOrtkHS5qUQCX_i0SL3ulk1HEgEUBzOQ/s320/eqn.bmp" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class="MsoNormal"&gt;
Hint: make use of multiplication ( a*a ) to calculate&amp;nbsp; squares&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;div class="MsoNormal"&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: 15px; line-height: 20px;"&gt;&lt;b&gt;&lt;a href="http://mycodedotc.blogspot.in/2012/09/chapter-5-implementing-float.html"&gt;Previous Post&lt;/a&gt; &amp;nbsp; &amp;nbsp; &lt;a href="http://mycodedotc.blogspot.in/2012/09/chapter-7-writing-our-own-program.html"&gt;Next Post&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2012/09/chapter-6-mathematics-operationspart-1.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuiuVzCXx2LcnauhwfcZE6wzRDCEX29CUxYw41qpAX5BUkbwsHUtoABwNSZkno3Y6iqsxNG980OJn-IiTfyAcRggcsIonZKLkZ8yyNdp_dfcrmU-Ulu5wDeCvpoDxGACyLBz5OPz7d1ao/s72-c/eqn.bmp" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-4110959794804389089</guid><pubDate>Tue, 04 Sep 2012 05:14:00 +0000</pubDate><atom:updated>2013-08-24T20:19:12.298+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Archive</category><title>Chapter 5 - Implementing Float</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shCore.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shBrushCpp.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
&lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
&lt;script type="text/javascript"&gt;
 SyntaxHighlighter.config.clipboardSwf = 'https://dl.dropbox.com/u/102425073/code/scripts/clipboard.swf';
 SyntaxHighlighter.all();
&lt;/script&gt;
From the &lt;a href="http://mycodedotc.blogspot.in/2012/08/chapter-4-implementing-int.html" target="_blank"&gt;previous chapter&lt;/a&gt; we learned how to use an integer using 3 steps
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;declaring an int&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;initializing an int&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;using the value stored in the int&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Now with this knowledge we will make use of float(decimal) values in our program.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
Float stands for decimal or floating point value. Every value stored in float contains a decimal point.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
In the last chapter i did not mention that a value from one variable can be used to initialize another variable. I have implemented this concept int the code below.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 4th September 2012  
 Title : prints the value of 2 variables previous and current  
*/  

#include&amp;lt;stdio.h&amp;gt;  
#include&amp;lt;conio.h&amp;gt;  

void main ()  
 {  
  float current =10.123, previous=0.0;  
  clrscr();  
  printf("The current value is : %f", current);
  previous = current;
  current = 23.344;
  getch();
  printf("\n\nThe current value is: %f \nThe previous value is: %f", current, previous);
  getch();  
 }
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
What we learn from this code is
&lt;br /&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;variables can be used to initialize other variables&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;variables can also be re initialized anywhere in the program&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;b&gt;Here instead of using %d we make use of &amp;nbsp;%f &amp;nbsp;for float values.&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;By default float shows 4 digits after the decimal point. To limit the number of digits after the decimal point we make use of %.3f.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Here &lt;b&gt;&lt;span style="font-size: large;"&gt;.3&lt;/span&gt;&lt;/b&gt; means&amp;nbsp;&lt;b&gt;&amp;nbsp;3 values after the decimal point. Hence we can make use of values 0, 1, 2, 3 or 4 only as 4 is the upper limit &lt;/b&gt;and negative values are not allowed obviously.&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
This is all there is to be learned about float, using the three steps specified above. The next chapter will show how we can make use of both integer and float values along with mathematical operators.

&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
&lt;span style="font-size: x-large;"&gt;Activities&lt;/span&gt;&lt;/h3&gt;
&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Use the same code to to show only 2 digits after the decimal point.&lt;/li&gt;
&lt;li&gt;Implement a code with both int and float values.&lt;/li&gt;
&lt;/ol&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: 15px; line-height: 20px;"&gt;&lt;b&gt;&lt;a href="http://mycodedotc.blogspot.in/2012/08/chapter-4-implementing-int.html"&gt;Previous Post&lt;/a&gt; &amp;nbsp; &amp;nbsp; &lt;a href="http://mycodedotc.blogspot.in/2012/09/chapter-6-mathematics-operationspart-1.html"&gt;Next Post&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2012/09/chapter-5-implementing-float.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-7125070507373726130</guid><pubDate>Fri, 31 Aug 2012 07:13:00 +0000</pubDate><atom:updated>2013-09-22T09:07:07.889+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Archive</category><title>Chapter 4 - Implementing the Int(integer)</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shCore.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shBrushCpp.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;script type="text/javascript"&gt;
  SyntaxHighlighter.config.clipboardSwf = 'https://dl.dropbox.com/u/102425073/code/scripts/clipboard.swf';
  SyntaxHighlighter.all();
 &lt;/script&gt;
Yes its Int and not IMP.&lt;br /&gt;
Int Data Type is one of the commonly used data types and used to store integer values. In the &lt;a href="http://mycodedotc.blogspot.in/2012/08/chapter-3-variables-and-introduction-to.html" target="_blank"&gt;previous chapter&lt;/a&gt;&amp;nbsp;i explained to you what an integer can store with examples. So by now it is clear what kind of data we want to store in our first &lt;b&gt;int variable&lt;/b&gt;. So lets get coding.&lt;br /&gt;
&lt;br /&gt;
There are 3 steps in using a&amp;nbsp;variable&amp;nbsp;in any program.&lt;b&gt;Variable declaration&lt;/b&gt;, where the compiler is told you are declaring a new variable of type INT.&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;&lt;b&gt;Variable initialization&lt;/b&gt;, where you store some value in the variable.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Actual use of variable.&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Example: The example code with give u a clear picture of how the three steps are used in the program and how we ca store and&amp;nbsp;retrieve&amp;nbsp;values from our (int) variables.&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 31st August 2012  
 Title : prints the value of a variable  
*/  

#include&amp;lt;stdio.h&amp;gt;  
#include&amp;lt;conio.h&amp;gt;  

void main ()  
 {  
  int x;  
  x =0;  
  clrscr();  
  printf("The value of x is : x");  
  getch();  
}    
&lt;/pre&gt;
&lt;a href="http://www.mediafire.com/download.php?5bs1uq68gpmo1a6" target="_blank"&gt;Download code&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Line 1 is implements&amp;nbsp;variable&amp;nbsp;declaration.&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Line 2 implements variable initialization.&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Line 3 makes use of the value of x .&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Run the code before you read further.&lt;/div&gt;
&lt;div&gt;
As you may have noticed this code doesn't print any number. This is because x is treated as a part of a sentence and not as a variable. Hence we need to tell the&amp;nbsp;compiler to reserve that space for an integer which is done by using a special word which is&lt;b&gt; %d&amp;nbsp;. &lt;/b&gt;So now the actual printf statement is&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class="brush: cpp;"&gt; printf("The value of x is : %d", x);    
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
This can be translated as, reserve space for a int variable whose name is x. So the new code becomes:
&lt;br /&gt;
&lt;div&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 31st August 2012  
 Title : prints the value of a variable  
*/  

#include&amp;lt;stdio.h&amp;gt;  
#include&amp;lt;conio.h&amp;gt;  
void main ()  
 {  
  int x =0;  
  clrscr();  
  printf("The value of x is : %d", x);  
  getch();  
 }
&lt;/pre&gt;
&lt;a href="http://www.mediafire.com/download.php?0n3y65vilz7qtt6" target="_blank"&gt;Download code&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
You ca see that i have made a few changes and here are some good practices that i want you all to follow to reduce errors. As you can see i have initialized the value of x where it is declared. The reason behind this is that if you forget to initialize your variable later it will create errors in your code and will take time to find the exact cause of error. Hence i&amp;nbsp;recommend&amp;nbsp;you to make a&amp;nbsp;habit&amp;nbsp;of initializing the variables when they are declared.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style="font-size: large;"&gt;&lt;b&gt;How to print Two int Variables ?&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
To print two variables we extend the same concept. Suppose that we have to variables&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class="brush: cpp;"&gt;int x = 1, y =3;    
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
(Yes you can declare more than one variable of the same type is the same sentence but you have to use int keyword only once, i.e. at the start of the instruction)&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
So now the accompanying printf statement will be:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class="brush: cpp;"&gt;printf("The value of x is : %d \n The value of y is : %d", x, y);  
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Note:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;&lt;span style="font-family: Times, Times New Roman, serif;"&gt;Changing the order of x and y in the print f statement will change the answer.&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;span style="font-family: Times, Times New Roman, serif;"&gt;There number of %d should match with the number of integer variables.&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;span style="font-family: Times, Times New Roman, serif;"&gt;The order in which different types of variables used inside " .... " must be the same outside. (You will understand what i mean later when we make use of different data types).&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;So the final code is:&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;pre class="brush: cpp;"&gt;/*  
 Author : Ryan Sequeira  
 Date : 31st August 2012  
 Title : prints the value of 2 variables in one printf  
*/  

#include&amp;lt;stdio.h&amp;gt;  
#include&amp;lt;conio.h&amp;gt;  

void main ()  
 {  
  int x =10, y=20;  
  clrscr();  
  printf("The value of x is : %d \n The value of y is : %d", x, y);  
  getch();  
 }
&lt;/pre&gt;
&lt;a href="http://www.mediafire.com/download.php?ytsk4ihffa78k84" target="_blank"&gt;Download code&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style="font-size: x-large;"&gt;Activities&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Try to change the value of x after the first printf and print the new value.&lt;/li&gt;
&lt;li&gt;Try to print two or more variables each in a different printf.&lt;/li&gt;
&lt;li&gt;Try to print more than one variables in the same printf.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style="text-align: center;"&gt;
&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: 15px; line-height: 20px;"&gt;&lt;b&gt;&lt;a href="http://mycodedotc.blogspot.in/2012/08/chapter-3-variables-and-introduction-to.html"&gt;Previous Post&lt;/a&gt; &amp;nbsp; &amp;nbsp; &lt;a href="http://mycodedotc.blogspot.in/2012/09/chapter-5-implementing-float.html"&gt;Next Post&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2012/08/chapter-4-implementing-int.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-2059801865810292707</guid><pubDate>Wed, 29 Aug 2012 17:12:00 +0000</pubDate><atom:updated>2013-09-21T20:57:06.066+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Archive</category><title>Chapter 3 - Variables and Introduction to Datatypes</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
In the &lt;a href="http://mycodedotc.blogspot.in/2012/08/chapter-2-formatting-text.html" target="_blank"&gt;previous chapter&lt;/a&gt;&amp;nbsp;we learned how to format and print our output. Now that we are familiar with the &lt;b&gt;printf()&amp;nbsp;&lt;/b&gt;function&amp;nbsp;we will move a step ahead. Those who have not mastered the printf() function please refer the previous chapter before continuing.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;So what is a variable?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Consider the following sentence:&lt;/b&gt; There are &lt;u&gt;40&lt;/u&gt; students in my class.&lt;br /&gt;
From this sentence we can say that there are exactly 40 students in the class.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Now consider this statement:&lt;/b&gt; There are&lt;b&gt; 'x' &lt;/b&gt;students in the class.&lt;br /&gt;
The value of &lt;b&gt;&amp;nbsp;'x' &lt;/b&gt;here can be any whole number(1,2,3... etc).&lt;br /&gt;
&lt;br /&gt;
We use variables in our programs to store data and the values of these variables can be changed at any time.&lt;br /&gt;
&lt;br /&gt;
Consider the following table. For different values of x we can print the same sentence, with the changing values.&lt;br /&gt;
&lt;br /&gt;
&lt;div align="center"&gt;
&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;"&gt;
 &lt;tbody&gt;
&lt;tr&gt;
  &lt;td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 63.9pt;" valign="top" width="85"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;X = 2&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 207.0pt;" valign="top" width="276"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
There are &lt;b&gt;2&lt;/b&gt; students in the class&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 63.9pt;" valign="top" width="85"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;X = 5&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 207.0pt;" valign="top" width="276"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
There are &lt;b&gt;5&lt;/b&gt; students in the class&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 63.9pt;" valign="top" width="85"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;X = 15&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 207.0pt;" valign="top" width="276"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
There are &lt;b&gt;15&lt;/b&gt; students in the class&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 63.9pt;" valign="top" width="85"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;X = 30&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 207.0pt;" valign="top" width="276"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
There are &lt;b&gt;30&lt;/b&gt; students in the class&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-size: large;"&gt;How are Data Types related with Variables?&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;
As x is a variable it can also store names, decimals and integers right.&lt;br /&gt;
Consider the following 3 sentences:&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;/div&gt;
&lt;div align="center"&gt;
&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;"&gt;
 &lt;tbody&gt;
&lt;tr&gt;
  &lt;td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 203.4pt;" valign="top" width="271"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
My name is &lt;b&gt;Ryan&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 85.5pt;" valign="top" width="114"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;X = “Ryan”&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 203.4pt;" valign="top" width="271"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
I scored &lt;b&gt;65.5&lt;/b&gt; % in the Exam&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 85.5pt;" valign="top" width="114"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;X =”65.5”&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 203.4pt;" valign="top" width="271"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
There were &lt;b&gt;15&lt;/b&gt; passengers in the bus.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 85.5pt;" valign="top" width="114"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;X = “15”&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div style="text-align: left;"&gt;
But another variation can be&amp;nbsp;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;div align="center"&gt;
&lt;table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-collapse: collapse; border: none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;"&gt;
 &lt;tbody&gt;
&lt;tr&gt;
  &lt;td style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 203.4pt;" valign="top" width="271"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
My name is 15&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 85.5pt;" valign="top" width="114"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;X = “15”&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 203.4pt;" valign="top" width="271"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
I scored Ryan % in the Exam&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 85.5pt;" valign="top" width="114"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;X = “Ryan”&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 203.4pt;" valign="top" width="271"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
There were 65.5 passengers in the bus.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 85.5pt;" valign="top" width="114"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;X = ”65.5”&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div style="text-align: left;"&gt;
This has no meaning. Hence the data&amp;nbsp;stored&amp;nbsp;in the variable must be of a particular type. Therefore&amp;nbsp;every time we create a variable we define the type of data that can be stored in the variable.&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
Hence for the above example the data types will be:&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;div align="center"&gt;
&lt;table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; mso-padding-alt: 0in 0in 0in 0in; mso-yfti-tbllook: 1184;"&gt;
 &lt;tbody&gt;
&lt;tr&gt;
  &lt;td style="border: solid windowtext 1.0pt; padding: 0in 5.4pt 0in 5.4pt; width: 203.4pt;" valign="top" width="271"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;My name is&amp;nbsp;&lt;b&gt;Ryan&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid windowtext 1.0pt; padding: 0in 5.4pt 0in 5.4pt; width: 85.5pt;" valign="top" width="114"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;X = “Ryan”&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-left: none; border: solid windowtext 1.0pt; padding: 0in 0in 0in 0in; width: 85.5pt;" valign="top" width="114"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;X is a Integer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; padding: 0in 5.4pt 0in 5.4pt; width: 203.4pt;" valign="top" width="271"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;I scored&amp;nbsp;&lt;b&gt;65.5&lt;/b&gt;&amp;nbsp;%
  in the Exam&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt; width: 85.5pt;" valign="top" width="114"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;X =”65.5”&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; padding: 0in 0in 0in 0in; width: 85.5pt;" valign="top" width="114"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;X is a Float&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;tr&gt;
  &lt;td style="border-top: none; border: solid windowtext 1.0pt; padding: 0in 5.4pt 0in 5.4pt; width: 203.4pt;" valign="top" width="271"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;There were&amp;nbsp;&lt;b&gt;15&lt;/b&gt;&amp;nbsp;passengers
  in the bus.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt; width: 85.5pt;" valign="top" width="114"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;X = “15”&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;
  &lt;td style="border-bottom: solid windowtext 1.0pt; border-left: none; border-right: solid windowtext 1.0pt; border-top: none; padding: 0in 0in 0in 0in; width: 85.5pt;" valign="top" width="114"&gt;&lt;div class="MsoNormal" style="margin-bottom: 0.0001pt;"&gt;
&lt;b&gt;&lt;span style="font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12.0pt; mso-fareast-font-family: &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;X is a String&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
Dont worry about the names, you will get used to them. We need to understand what each type means. Examples will clear all your doubts.&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span style="font-size: large;"&gt;&lt;b&gt;Data Types supported by C:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
(Don't get scared by looking at the list and the numbers, it will all make sense afterwards)&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit8wi_RLStOo4FRecrKPLZCKVMkHbUNa2gzEGnGQmTrJJtiOvE_BqnTehlS5jlnxu_5aeicoLcUQiCpR48dZtHfT8z9DOKS27_k8npXOomBYh3Gz8q7xLk1vVrG15GPeqfODvdDn-CRqw/s1600/184589.image0.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit8wi_RLStOo4FRecrKPLZCKVMkHbUNa2gzEGnGQmTrJJtiOvE_BqnTehlS5jlnxu_5aeicoLcUQiCpR48dZtHfT8z9DOKS27_k8npXOomBYh3Gz8q7xLk1vVrG15GPeqfODvdDn-CRqw/s1600/184589.image0.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
They first column stands for the Data Type.&amp;nbsp;The second column stands for the meaning and the third one for the range of values. The basic types are &lt;b&gt;int , float and char &lt;/b&gt;, the remaining are rarely used and can be dealt with later on.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;But why do all the Data Types have a range ?&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As we know variables store information, and all the information stored in the computer requires memory. But we also know that our computer has limited memory. As the size of information increases &amp;nbsp;more memory is required. So we need to put a restriction on the size of information/data stored in the variable. Hence &lt;b&gt;every data type has a fixed size and fixed range&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Remember, you need to&lt;b&gt;&lt;u&gt; Treat Every New Concept as an Opportunity to Improve&lt;/u&gt;&lt;/b&gt; and not as an Hurdle&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style="text-align: left;"&gt;
&lt;/h4&gt;
&lt;h4&gt;
&lt;b style="font-size: x-large;"&gt;1) Integer Data Type&lt;/b&gt;&lt;/h4&gt;
&lt;div style="font-weight: normal;"&gt;
&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;Example:&lt;/span&gt;&amp;nbsp;1, 2, 0, -8, 5123, -8932, etc.&lt;/b&gt;&lt;/div&gt;
&lt;div style="font-weight: normal;"&gt;
&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;Description:&lt;/span&gt;&amp;nbsp;Used to store integer values. They can be negative, zero and positive.&lt;/b&gt;&lt;/div&gt;
&lt;div style="font-weight: normal;"&gt;
&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;Range:&lt;/span&gt;&amp;nbsp;-32768 to 32767&lt;/b&gt;&lt;/div&gt;
&lt;div style="font-weight: normal;"&gt;
&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;Size:&lt;/span&gt;&amp;nbsp;2 Bytes&lt;/b&gt;&lt;/div&gt;
&lt;div style="font-weight: normal;"&gt;
&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;Syntax:&lt;/span&gt;&amp;nbsp;int x= 5;&lt;/b&gt;&lt;/div&gt;
&lt;br class="Apple-interchange-newline" /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;h4&gt;
&lt;b style="font-size: x-large;"&gt;2) Float Data Type&lt;/b&gt;&lt;/h4&gt;
&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;Example:&lt;/span&gt;&amp;nbsp;1.5621, 2.00, 0.435, -8.021, etc.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;Description:&lt;/span&gt;&amp;nbsp;Used to store decimal values. They can be negative, zero and positive.&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;Range:&lt;/span&gt;&amp;nbsp;&lt;span style="background-color: white; color: #333333; font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 13px; text-align: center;"&gt;-3.4e&lt;/span&gt;&lt;sup style="background-color: white; color: #333333; font-family: Verdana, Tahoma, Arial, sans-serif; margin: 0px; padding: 0px; text-align: center;"&gt;38&lt;/sup&gt;&lt;span style="background-color: white; color: #333333; font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 13px; text-align: center;"&gt;&amp;nbsp;to +3.4e&lt;/span&gt;&lt;sup style="background-color: white; color: #333333; font-family: Verdana, Tahoma, Arial, sans-serif; margin: 0px; padding: 0px; text-align: center;"&gt;38&lt;/sup&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;Size:&lt;/span&gt;&amp;nbsp;4 Bytes&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;Syntax:&lt;/span&gt;&amp;nbsp;float x= 5.43;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;h4&gt;
&lt;b style="font-size: x-large;"&gt;3) Character Data Type&lt;/b&gt;&lt;/h4&gt;
&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;Example:&lt;/span&gt;&amp;nbsp;a, g, t, B, T, Z etc. Also 1, 2, 3 etc and symbols like +, %, # etc. But&amp;nbsp;don't&amp;nbsp;confuse these numbers with integers as we cannot apply any mathematical operations on them. It is just to print numbers.&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;Description:&lt;/span&gt;&amp;nbsp;Used to store&amp;nbsp;&lt;u&gt;a single Character&lt;/u&gt;.&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;Range:&lt;/span&gt;&amp;nbsp;&lt;/b&gt;&lt;span style="background-color: white; color: #333333; font-family: Verdana, Tahoma, Arial, sans-serif; font-size: 13px; text-align: center;"&gt;&lt;b&gt;-128 to +127&lt;/b&gt;&amp;nbsp;(&lt;a href="http://www.cdrummond.qc.ca/cegep/informat/professeurs/alain/images/ASCII1.GIF" target="_blank"&gt;ASCII values of characters&lt;/a&gt;)&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;Size:&lt;/span&gt;&amp;nbsp;1 Byte&amp;nbsp;&lt;/b&gt;(notice the size difference between int and char)&lt;br /&gt;
&lt;b&gt;&lt;span style="color: #3d85c6;"&gt;Syntax:&lt;/span&gt;&amp;nbsp;int x= 'c';&lt;/b&gt;&amp;nbsp;&amp;nbsp;(always write the value inside single quote(&lt;b&gt;'&lt;/b&gt;))&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&amp;nbsp;U might want to know how to store a name. I will answer it after some posts as it is an extension on Data Types and one needs to get familiar with these first before moving ahead.&lt;br /&gt;
&lt;br /&gt;
Finally u might be&amp;nbsp;exhausted reading a post this long and hence there wont be any tutorial. I recommend the student to be fresh before learning something new and hence end this post here.&lt;br /&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"&gt;&lt;a href="http://mycodedotc.blogspot.in/2012/08/chapter-2-formatting-text.html"&gt;Previous Post&lt;/a&gt; &amp;nbsp; &amp;nbsp; &lt;a href="http://mycodedotc.blogspot.in/2012/08/chapter-4-implementing-int.html"&gt;Next Post&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2012/08/chapter-3-variables-and-introduction-to.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEit8wi_RLStOo4FRecrKPLZCKVMkHbUNa2gzEGnGQmTrJJtiOvE_BqnTehlS5jlnxu_5aeicoLcUQiCpR48dZtHfT8z9DOKS27_k8npXOomBYh3Gz8q7xLk1vVrG15GPeqfODvdDn-CRqw/s72-c/184589.image0.jpg" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-2853717908554576464</guid><pubDate>Sun, 26 Aug 2012 06:53:00 +0000</pubDate><atom:updated>2013-08-31T21:23:59.368+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Archive</category><title>Chapter 2 - Formatting the Text</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
   &lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shCore.js" type="text/javascript"&gt;&lt;/script&gt;
   &lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shBrushCpp.js" type="text/javascript"&gt;&lt;/script&gt;
   &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shCore.css" rel="stylesheet" type="text/css"&gt;
   &lt;/link&gt;
   &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;
   &lt;/link&gt;
   &lt;script type="text/javascript"&gt;
      SyntaxHighlighter.config.clipboardSwf = 'https://dl.dropbox.com/u/102425073/code/scripts/clipboard.swf';
      SyntaxHighlighter.all();
   &lt;/script&gt;
   &lt;br /&gt;
   In our &lt;a href="http://mycodedotc.blogspot.in/2012/08/chapter-1-structure-of-c-program.html" target="_blank"&gt;previous chapter&lt;/a&gt;&amp;nbsp;we wrote a program to print a line on the output screen which read&lt;br /&gt;
   &lt;blockquote class="tr_bq" style="text-align: center;"&gt;
      &lt;b&gt;"This is my first program"&lt;/b&gt;
   &lt;/blockquote&gt;
   So now moving a step ahead lets try to figure out how to write two lines which will look like this.&lt;br /&gt;
   &lt;blockquote class="tr_bq"&gt;
      &lt;div style="text-align: center;"&gt;
         &lt;b&gt;"This is the first line"&lt;/b&gt;
      &lt;/div&gt;
      &lt;div style="text-align: center;"&gt;
         &lt;b&gt;"This is the second line"&amp;nbsp;&lt;/b&gt;
      &lt;/div&gt;
   &lt;/blockquote&gt;
   Any suggestions on how u think it can be done?&lt;br /&gt;
   You may think of using two lines of printf(). So now the code looks like this :&lt;br /&gt;
   &lt;br /&gt;
   &lt;pre class="brush: cpp;"&gt;   /*   
    Title: simple code that prints two lines.   
    Author: Ryan Sequeira   
    Created on: 25th August 2012   
   */   

   #include&amp;lt;stdio.h&amp;gt;   
   #include&amp;lt;conio.h&amp;gt;   

   void main()   
    {   
     // no need for local variables   
     clrscr();   
     printf("This is the first line");   
     printf("This is the second line");   
     getch();  
    }  
&lt;/pre&gt;
   &lt;br /&gt;
   Try executing this code before reading further and see what actually happens.&lt;br /&gt;
   &lt;br /&gt;
   So it&amp;nbsp;didn't&amp;nbsp;turn out as you expected. The problem here is the compiler doesn't understand when it has to insert a new line(even if you use separate printf's). It prints it as a single sentence from left to right and then top to bottom in a new line.&lt;br /&gt;
   &lt;br /&gt;
   To get the the expected result you have to tell the compiler &lt;b&gt;explicitly &lt;/b&gt;to insert a line break where ever you need it. So now here is the magic code that will give u the expected result.&lt;br /&gt;
   &lt;br /&gt;
   &lt;pre class="brush: cpp;"&gt;    printf("This is the first line");   
    printf("\nThis is the second line");  
&lt;/pre&gt;
   &lt;br /&gt;
   Yes the &lt;b&gt;'\n' &lt;/b&gt;is the secret word that tells the compiler to insert a line break and hence print the next sentence in a new line. If you want you can use a single printf statement to reduce the size of the code.&lt;br /&gt;
   &lt;br /&gt;
   &lt;pre class="brush: cpp;"&gt; printf("This is the first line \nThis is the second line");   
&lt;/pre&gt;
   &lt;br /&gt;
   Now try to implement the changes in the previous code and compare the results with what is expected.&lt;br /&gt;
   If you are not able to figure it out, i have written the expected code below.&lt;br /&gt;
   &lt;br /&gt;
   &lt;pre class="brush: cpp;"&gt;/*   
   Title: simple code that prints two lines.   
   Author: Ryan Sequeira   
   Created on: 25th August 2012   
*/
   
#include&amp;lt;stdio.h&amp;gt;   
#include&amp;lt;conio.h&amp;gt;   

void main()   
 {   
  // no need for local variables   
  clrscr();   
  printf("This is the first line");   
  printf("\nThis is the second line");   
  getch();   
 }   
&lt;/pre&gt;
   &lt;br /&gt;
   This is not all, there are a few surprises left. Now that you know how to insert a new like there are other formatting&amp;nbsp;options&amp;nbsp;too.
   &lt;br /&gt;
   &lt;br /&gt;
   &lt;ul&gt;
      &lt;li&gt;&lt;b&gt;\n &amp;nbsp; &amp;nbsp; new line&lt;/b&gt;&lt;/li&gt;
      &lt;li&gt;&lt;b&gt;\t &amp;nbsp; &amp;nbsp; &amp;nbsp;horizontal tab&lt;/b&gt;&lt;/li&gt;
      &lt;li&gt;\r &amp;nbsp; &amp;nbsp; &amp;nbsp;carriage return&lt;/li&gt;
      &lt;li&gt;\" &amp;nbsp; &amp;nbsp; &amp;nbsp;double quote&lt;/li&gt;
      &lt;li&gt;\\ &amp;nbsp; &amp;nbsp; &amp;nbsp;backslash&lt;/li&gt;
      &lt;li&gt;\a &amp;nbsp; &amp;nbsp; alert (BEL)&lt;/li&gt;
      &lt;li&gt;\b &amp;nbsp; &amp;nbsp; backspace&lt;/li&gt;
   &lt;/ul&gt;
   &lt;div&gt;
      Although there are a lot of options to format the text, I would advice you to only use the two of them highlighted(\n and \t).
   &lt;/div&gt;
  So now that you are comfortable with the use of \n(line break) in the sentences we will introduce \t(tabs) in our sentences.
Example:
Try to write a code on your own to print the following paragraph, with the tabs and line breaks
   &lt;pre&gt;&lt;b&gt;                  This is the first line.&lt;/b&gt;
&lt;b&gt;                           This is the second line.&lt;/b&gt;
&lt;b&gt;                                    This is the third line.&lt;/b&gt;&lt;/pre&gt;
Hint: The number of tabs increase every new line.
If you managed to write your own code and want to compare it with the expected code, or if you didn't get the solution then check the ideal code below.
   &lt;br /&gt;
   &lt;pre class="brush: cpp;"&gt;/*   
 Title: simple code that prints two lines.   
 Author: Ryan Sequeira   
 Created on: 25th August 2012   
*/   

#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;conio.h&amp;gt;   

void main()   
 {   
  // no need for local variables   
  clrscr();   
  printf("This is the first line");   
  printf("\n\tThis is the second line");   
  printf("\n\t\t This is the third line");      
  getch();   
 }    
&lt;/pre&gt;
   &lt;br /&gt;
   &lt;b&gt;&lt;span style="font-size: x-large;"&gt;Activities&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
   &lt;ol&gt;
      &lt;span style="font-family: inherit;"&gt;
         &lt;li&gt;&lt;span style="font-family: inherit;"&gt;Try to pick any paragraph from your book and then print it with all the tabs and line breaks.&lt;/span&gt;&lt;/li&gt;
         &lt;li&gt;&lt;span style="font-family: inherit;"&gt;Try to print the following design.(&lt;/span&gt;&lt;a href="http://www.mediafire.com/download.php?bigpa6ydogly7m4" style="font-family: inherit;" target="_blank"&gt;Solution&lt;/a&gt;&lt;span style="font-family: inherit;"&gt;)&lt;/span&gt;&lt;/li&gt;
      &lt;/span&gt;
   &lt;/ol&gt;
   &lt;span style="font-family: inherit;"&gt;
   &lt;/span&gt;
   &lt;br /&gt;
   &lt;div&gt;
      &lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/b&gt;&lt;span style="font-family: Courier New, Courier, monospace;"&gt;&lt;b&gt;*&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
      &lt;span style="font-family: Courier New, Courier, monospace;"&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
      &lt;span style="font-family: Courier New, Courier, monospace;"&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
      &lt;span style="font-family: Courier New, Courier, monospace;"&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
      &lt;span style="font-family: Courier New, Courier, monospace;"&gt;&lt;b&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
      &lt;span style="font-family: Courier New, Courier, monospace;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
      &lt;br /&gt;
      &lt;div style="text-align: center;"&gt;
         &lt;b style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;&lt;a href="http://mycodedotc.blogspot.in/2012/08/chapter-1-structure-of-c-program.html"&gt;Previous Post&lt;/a&gt;&lt;/b&gt;&lt;span style="background-color: white;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;b style="background-color: white; color: #333333; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 15px; line-height: 20px;"&gt;&lt;span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;a href="http://mycodedotc.blogspot.in/2012/08/chapter-3-variables-and-introduction-to.html"&gt;Next Post&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;
      &lt;/div&gt;
      &lt;br /&gt;
   &lt;/div&gt;
   
   &lt;div style="text-align: left;"&gt;&lt;/div&gt;
   &lt;div style="text-align: left;"&gt;&lt;/div&gt;
   &lt;div&gt;&lt;/div&gt;
   &lt;div&gt;&lt;/div&gt;
   &lt;div&gt;&lt;/div&gt;
&lt;/div&gt;</description><link>http://mycodedotc.blogspot.com/2012/08/chapter-2-formatting-text.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-3867981276624493782.post-978903531255741705</guid><pubDate>Fri, 24 Aug 2012 04:36:00 +0000</pubDate><atom:updated>2013-08-24T20:18:24.874+05:30</atom:updated><category domain="http://www.blogger.com/atom/ns#">Archive</category><title>Chapter 1 - The structure of a C program</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shCore.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;script src="https://dl.dropbox.com/u/102425073/code/scripts/shBrushCpp.js" type="text/javascript"&gt;&lt;/script&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shCore.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;link href="https://dl.dropbox.com/u/102425073/code/styles/shThemeDefault.css" rel="stylesheet" type="text/css"&gt;&lt;/link&gt;
 &lt;script type="text/javascript"&gt;
  SyntaxHighlighter.config.clipboardSwf = 'https://dl.dropbox.com/u/102425073/code/scripts/clipboard.swf';
  SyntaxHighlighter.all();
 &lt;/script&gt;

Before we start &amp;nbsp;with programming let c understand what a c program looks like&lt;br /&gt;
&lt;br /&gt;
&lt;style type="text/css"&gt;
pre.CICodeFormatter{
 font-family:arial;
 font-size:12px;
 border:1px dashed #CCCCCC;
 width:99%;
 height:auto;
 overflow:auto;
 background:#f0f0f0;
 line-height:20px;
 background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRIkGGuV-780VHeIpZQeanlizP2IOAxnmAF6D9dr5JkKxH86kxfUN6QXipahJAPvrqX-W7dm_em-TZdjeCPeB32FbtjWprYK1nu4gtyYXCemzC47wNrhv_Km5p_KJQ2XP0aS8sw7LK3RT1/s320/codebg.gif);
 padding:0px;
 color:#000000;
 text-align:left;
}
pre.CICodeFormatter code{
 color:#000000;
 word-wrap:normal;
}
&lt;/style&gt;

&lt;br /&gt;
&lt;pre class="CICodeFormatter"&gt;&lt;code class="CICodeFormatter"&gt;1:  &lt;span style="color: #cc0000;"&gt;Preprocessor Declerations  &lt;/span&gt;
2:  Function Declerations  
3:  Global Variables  
4:  &lt;span style="color: #cc0000;"&gt;void main()  &lt;/span&gt;
5: &lt;span style="color: #cc0000;"&gt; { &lt;/span&gt;&lt;span style="color: red;"&gt; &lt;/span&gt;
6:   &lt;span style="color: red;"&gt;  &lt;/span&gt;&lt;span style="color: #cc0000;"&gt;/*Local Vaciable Declarations*/  &lt;/span&gt;
7:     &lt;span style="color: #cc0000;"&gt;clrscr(); &lt;/span&gt;&lt;span style="color: red;"&gt; &lt;/span&gt;
8:    &lt;span style="color: red;"&gt; &lt;/span&gt;&lt;span style="color: #cc0000;"&gt;/*Your Program code*/ &lt;/span&gt;&lt;span style="color: red;"&gt; &lt;/span&gt;
9:     &lt;span style="color: #cc0000;"&gt;getch();  &lt;/span&gt;
10:  &lt;span style="color: #cc0000; font-size: small;"&gt;}&lt;/span&gt;&lt;span style="color: red;"&gt; &lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
I know you didn't&amp;nbsp;understand a word written above,&amp;nbsp;don't&amp;nbsp;worry it will take time to get used to these programming constructs.&lt;br /&gt;
&lt;br /&gt;
For now lets consider only the part of the code written in &lt;b&gt;&lt;span style="color: #cc0000;"&gt;red.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
To make things simpler to understand let me use a small code which prints a statement.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp;"&gt;  /*  
    Title: simple code that prints a line.  
    Author: Ryan Sequeira  
    Created on: 24th August 2012  
  */  

  #include&amp;lt;stdio.h&amp;gt;  
  #include&amp;lt;conio.h&amp;gt;  

  void main()  
   {  
      // no need for local variables  
      clrscr();  
      printf("This is my first program");  
      getch();  
   }  
&lt;/pre&gt;
&lt;b&gt;(use the options on the&amp;nbsp;right&amp;nbsp;top side of the code to view, copy or print the code)&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Lets understand the code line wise&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;b&gt;#include&amp;lt;stdio.h&amp;gt; and #include&amp;lt;conio.h&amp;gt;: &lt;/b&gt;&amp;nbsp;This is what a preprocessor directive looks like. The main use of this is to include ready made functions to our program. Notice how i used "&lt;i&gt;&lt;u&gt;printf("This is my first program");&lt;/u&gt;&lt;/i&gt;" in line 6. The implementation of printf is already written in the header file&lt;i style="font-weight: bold;"&gt; stdio.h &lt;/i&gt;which we simply include in our program. So #include&amp;lt;stdio.h&amp;gt; can be translate into simple english sentence as "Include (all the functions written in the header) stdio.h in my program".&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;b&gt;void main() : &lt;/b&gt;This is where you start with your first line of code. The execution on the program starts from here. void main is the &lt;i&gt;&lt;u&gt;&lt;b&gt;Main function or the Starting point&lt;/b&gt;&lt;/u&gt;&amp;nbsp;&lt;/i&gt;of your code. It is also a function, but lets forget about that for now.&lt;/li&gt;
&lt;/ul&gt;
&lt;center&gt;
&lt;div style="background-color: #eeeeee; border-style: solid; border-width: 1px; padding: 10px; text-align: left; width: 80%;"&gt;
Note that &amp;lt;conio.h&amp;gt; i.e. the conio header is not a standard header and may not work with all the compilers. For those who are working on linux or unix (mac) platforms please skip conio.h along with the getch().&lt;/div&gt;
&lt;/center&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;b&gt;{....} : &lt;/b&gt;Let us consider void main as a electronic device, say a mobile phone. All the parts of the mobile phone are enclosed inside its casing. Similarly blocks of code are written within&lt;u&gt; &lt;/u&gt;&lt;i&gt;&lt;u&gt;&lt;b&gt;parenthesis {} also called Indentations&lt;/b&gt;&lt;/u&gt;.&amp;nbsp;&lt;/i&gt;Indentations&amp;nbsp;play a very important role in structuring the code and odd number of indentations are often the cause of many errors. So remember &lt;i style="font-weight: bold;"&gt;Every opening { &amp;nbsp;must have a closing }&lt;/i&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;b&gt;//no need for variables : &lt;/b&gt;Text written within /* ....... &amp;nbsp;*/ or // is ignored by the compiler. These lines are &amp;nbsp;called as comments and are written for description about the code.&lt;i&gt;&lt;b&gt; // is used for single line comment&lt;/b&gt;&amp;nbsp;&lt;/i&gt;where as&amp;nbsp;&lt;b&gt;&lt;i&gt; /* ... */ is used for multiple line comments&lt;/i&gt;. &lt;/b&gt;You can consider /* as opening bracket and */ as closing bracket and everything written inside it will be the comment.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;b&gt;clrscr(): &lt;/b&gt;It is a function implemented in conio.h. The job of this function is to clear all the contents of the output screen before printing the new output.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;b&gt;printf("This is my first program"):&lt;/b&gt; printf() is a function that is used to print output in your output screen. It is implemented in the header file stdio.h &amp;nbsp;and anything written inside "..." will be printed.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;b&gt;getch():&lt;/b&gt; I will explain you what this exactly is later. For now all you need to know is that this is implemented in conio.h header file. What it does is stops the execution of the program on line 13 until you press any key. Once you press any key the last line will get executed and the program will close.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
If you have understood everything above try the activities listed below. If you have any doubts feel free to comment.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
A complete tutorial to create and run the code can be found &lt;b&gt;&lt;a href="http://mycodedotc.blogspot.in/2012/08/how-to-create-and-run-c-program.html" target="_blank"&gt;here&lt;/a&gt;.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;NOTE&lt;/b&gt;: Remember&amp;nbsp;every time the program pauses you have to press any key&amp;nbsp;, this happens because u have&amp;nbsp;interrupted&amp;nbsp;the execution of the program by adding getch(). so if you know there are 2 getch's in the code you will have to press any key(preferable enter) 2 times for the program to end.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;Activities:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;ol style="text-align: left;"&gt;
&lt;li&gt;Try to close the computer screen and write down the structure of the C program on your own. Lets see how much of it you remember. Repeat this till u get it right.&lt;/li&gt;
&lt;li&gt;Copy the same code and see what happens if you remove &amp;nbsp;the block of code with &amp;nbsp; &amp;nbsp; &amp;nbsp;/* ..........*/&amp;nbsp;and the line&amp;nbsp;
//no need for variables&amp;nbsp;&amp;nbsp;.&lt;/li&gt;
&lt;li&gt;Try removing &lt;u&gt;clrscr();&lt;/u&gt; and check the output.&lt;/li&gt;
&lt;li&gt;Try the above code without &lt;u&gt;getch();&lt;/u&gt;&lt;/li&gt;
&lt;li&gt;Add the following lines to your code after line 13 . repeat this any number of times and keep changing the text in " ... ".&lt;/li&gt;
&lt;/ol&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf("This is a new line")&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;getch();&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="text-align: center;"&gt;
&lt;b&gt;&lt;span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"&gt;&lt;a href="http://mycodedotc.blogspot.in/2012/08/chapter-2-formatting-text.html"&gt;Next Post&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: red;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
</description><link>http://mycodedotc.blogspot.com/2012/08/chapter-1-structure-of-c-program.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item></channel></rss>