<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Zero Intellect &#187; Programming</title>
	<atom:link href="http://www.zerointellect.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zerointellect.com</link>
	<description>Technology Blog requiring Zero Intellect to follow !!!</description>
	<lastBuildDate>Mon, 28 Jun 2010 14:09:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Overview of a structure in C and C++</title>
		<link>http://www.zerointellect.com/programming/overview-of-a-structure-in-c-and-c/</link>
		<comments>http://www.zerointellect.com/programming/overview-of-a-structure-in-c-and-c/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 05:03:37 +0000</pubDate>
		<dc:creator>zrydento</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[data type]]></category>
		<category><![CDATA[record data fields]]></category>
		<category><![CDATA[record selector]]></category>
		<category><![CDATA[struct]]></category>
		<category><![CDATA[struct type name]]></category>
		<category><![CDATA[structure]]></category>
		<category><![CDATA[structure variable]]></category>
		<category><![CDATA[variable name]]></category>

		<guid isPermaLink="false">http://www.zerointellect.com/?p=254</guid>
		<description><![CDATA[<p> </p>
<p>The following article gives a brief overview of the structure in C/C++. The structure was first introduced in C where the need to group variables into a single record arose. Variables normally were assigned a single value or were assigned multiple values of the same type (array). The introduction of the structure allowed for variables to <p>Continue reading <a href="http://www.zerointellect.com/programming/overview-of-a-structure-in-c-and-c/">Overview of a structure in C and C++</a></p>]]></description>
			<content:encoded><![CDATA[<p> </p>
<p>The following article gives a brief overview of the structure in C/C++. The structure was first introduced in C where the need to group variables into a single record arose. Variables normally were assigned a single value or were assigned multiple values of the same type (array). The introduction of the structure allowed for variables to contain records of multiple values of different types. A simple comparison is displayed in the figure below</p>
<p><img class="aligncenter" src="http://www.zerointellect.com/uploads/05122009-diagram-1-1.png" alt="" width="350" height="375" /></p>
<p>A structure is of the format below and consists of 3 major components</p>
<p>1. struct-type-name<br />
2. structure-variable<br />
3. record data fields (data type, variable-name)</p>
<p> </p>
<blockquote><p>struct [<strong>&lt;struct-type-name&gt;</strong>]<br />
{<br />
 [<strong>&lt;type&gt;</strong> <strong>&lt;variable-names&gt;</strong>];<br />
 [<strong>&lt;type&gt;</strong> <strong>&lt;variable-names&gt;</strong>];<br />
 [<strong>&lt;type&gt;</strong> <strong>&lt;variable-names&gt;</strong>];<br />
 &#8230;<br />
}[<strong>&lt;structure-variables&gt;</strong>];</p></blockquote>
<p>The &lt;struct-type-name&gt; is an optional tag name that refers to the structure type. It should be defined to give a reflection of the contents of the structure. Such as &#8216;student&#8217; to indicate a record of student details. The &lt;structure-variables&gt; are the data definitions, and are also optional.</p>
<p>Though both are optional, one of the two must appear (makes logical sense, otherwise we would not be able to retrieve or store any values in the records). Elements in the record are defined by naming a &lt;type&gt;, followed by &lt;variable-names&gt; separated by commas. Different variable types can be separated by a semicolon.</p>
<p>A sample program follows that has a single record structure-variable as well as a structure-variable that holds 2 records</p>
<p> </p>
<p><strong># include &lt;iostream.h&gt;<br />
# include &lt;conio.h&gt;</strong></p>
<p><strong>void main()<br />
{<br />
 clrscr();</strong></p>
<p><strong> struct contact<br />
 {<br />
  char name[20];<br />
  int age;<br />
 }mrx;</strong></p>
<p><strong> cout&lt;&lt;&#8221;Name: &#8220;;<br />
 cin&gt;&gt;mrx.name;<br />
 cout&lt;&lt;&#8221;Age: &#8220;;<br />
 cin&gt;&gt;mrx.age;<br />
 cout&lt;&lt;&#8221;\nmrx.name : &#8220;&lt;&lt;mrx.name&lt;&lt;&#8221;\nmrx.age : &#8220;&lt;&lt;mrx.age;</strong></p>
<p><strong> struct contact family[2];</strong></p>
<p><strong> cout&lt;&lt;&#8221;\n\nEnter details of Family Members&#8230;\n&#8221;;</strong></p>
<p><strong> for(int i=0;i&lt;2;i++)<br />
 {<br />
  cout&lt;&lt;&#8221;\nName: &#8220;;<br />
  cin&gt;&gt;family[i].name;<br />
  cout&lt;&lt;&#8221;Age: &#8220;;<br />
  cin&gt;&gt;family[i].age;<br />
 }</strong></p>
<p><strong> cout&lt;&lt;&#8221;\nDetails of Family Members&#8230;&#8221;;</strong></p>
<p><strong> for(i=0;i&lt;2;i++)<br />
 {<br />
  cout&lt;&lt;&#8221;\n\nName :\t&#8221;&lt;&lt;family[i].name&lt;&lt;&#8221;\nAge :\t&#8221;&lt;&lt;family[i].age;<br />
 } <br />
      <br />
 getch();<br />
}</strong></p>
<p> </p>
<p>To access elements in a structure, you use a record selector (.)</p>
<p>For example, as it is mentioned in the program above mrx.age</p>
<p>To declare additional variables of the same type, you use the keyword struct followed by the &lt;struct-type-name&gt;, followed by the variable names</p>
<p>For example, the following declaration will create a record of 5 rows containing colleague details (age, name) as per our example program above</p>
<p><strong>struct colleagues[5];</strong></p>
<p>To summarize, structures were created to hold records of different data type values. But in C++ which is an object oriented language, classes were introduced that have many more benefits than structures. However, for simple implementations structures are very useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zerointellect.com/programming/overview-of-a-structure-in-c-and-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>C++ printing out a specific pattern</title>
		<link>http://www.zerointellect.com/programming/c-printing-out-a-specific-pattern/</link>
		<comments>http://www.zerointellect.com/programming/c-printing-out-a-specific-pattern/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 09:33:06 +0000</pubDate>
		<dc:creator>zrydento</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[for loop]]></category>
		<category><![CDATA[logic]]></category>
		<category><![CDATA[pattern]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://www.zerointellect.com/?p=108</guid>
		<description><![CDATA[<p> </p>
<p>Sometimes we come across elementary C++ programming tasks but which require you to tax your brain because of the logic involved</p>
<p> </p>
<p>I came across a question which asked the user to write a c++ program to print the pattern above for any value of N (where N are the number of rows)</p>
<p>1234554321</p>
<p>1234**4321</p>
<p>123****321</p>
<p>12******21</p>
<p>1********1</p>
<p> </p>
<p>The solution to the problem can <p>Continue reading <a href="http://www.zerointellect.com/programming/c-printing-out-a-specific-pattern/">C++ printing out a specific pattern</a></p>]]></description>
			<content:encoded><![CDATA[<p> </p>
<p>Sometimes we come across elementary C++ programming tasks but which require you to tax your brain because of the logic involved</p>
<p> </p>
<p>I came across a question which asked the user to write a c++ program to print the pattern above for any value of N (where N are the number of rows)</p>
<blockquote><p><strong>1234554321</strong></p>
<p><strong>1234**4321</strong></p>
<p><strong>123****321</strong></p>
<p><strong>12******21</strong></p>
<p><strong>1********1</strong></p></blockquote>
<p> </p>
<p>The solution to the problem can be tackled in many ways. I would like to demonstrate one method and logic to get the desired output</p>
<p>Firstly, the sequence can be broken down as two separate problems as per the figure below</p>
<p> </p>
<p><img class="aligncenter" src="http://www.zerointellect.com/uploads/0000002-diagram.png" alt="" width="350" height="150" /></p>
<p> </p>
<p>Various types of loops can be used but the central idea is the row is incremented from 1 to N, column 1 is incremented from 1 to N and column 2 is decremented from N to 1</p>
<p> </p>
<p>I quickly wrote the program below using the logic above with the help of for loops</p>
<p> </p>
<blockquote><p><strong># include &lt;iostream.h&gt;</strong></p>
<p><strong># include &lt;conio.h&gt;</strong></p>
<p><strong> </strong></p>
<p><strong>void main()</strong></p>
<p><strong>{</strong></p>
<p><strong>   clrscr();</strong></p>
<p><strong> </strong></p>
<p><strong>   int max=5;</strong></p>
<p><strong> </strong></p>
<p><strong>   for(int row=1;row&lt;=max;row++)</strong></p>
<p><strong>   {</strong></p>
<p><strong>         for(int column1=1;column1&lt;=max;column1++)</strong></p>
<p><strong>         {       </strong></p>
<p><strong>               if(column1&lt;=max-row+1)</strong></p>
<p><strong>               cout&lt;&lt;column1;</strong></p>
<p><strong>               else</strong></p>
<p><strong>               cout&lt;&lt;&#8221;*&#8221;;</strong></p>
<p><strong>         }</strong></p>
<p><strong> </strong></p>
<p><strong>         int drawstars=row-1;</strong></p>
<p><strong> </strong></p>
<p><strong>         for(int column2=max;column2&gt;=1;column2&#8211;)</strong></p>
<p><strong>         {</strong></p>
<p><strong>               if(drawstars&gt;0)</strong></p>
<p><strong>               cout&lt;&lt;&#8221;*&#8221;;</strong></p>
<p><strong>               else</strong></p>
<p><strong>               cout&lt;&lt;column2;</strong></p>
<p><strong> </strong></p>
<p><strong>               drawstars&#8211;;</strong></p>
<p><strong>         }</strong></p>
<p><strong>         cout&lt;&lt;&#8221;\n&#8221;;</strong></p>
<p><strong>   }</strong></p>
<p><strong>   getch();</strong></p>
<p><strong>}</strong></p></blockquote>
<p> </p>
<p> The program is self explanatory and a screenshot of the output of the sample above is as under</p>
<p> </p>
<p><img class="aligncenter" src="http://www.zerointellect.com/uploads/0000002-output.png" alt="" width="500" height="260" /> </p>
<p> </p>
<p>Many similar questions are asked where different outputs are desired, but the central idea to solving the question is figuring out a pattern that is being followed</p>
<p> </p>
<p>Happy Coding<span> </span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zerointellect.com/programming/c-printing-out-a-specific-pattern/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Types of Data Objects in C++</title>
		<link>http://www.zerointellect.com/programming/types-of-data-objects-in-c/</link>
		<comments>http://www.zerointellect.com/programming/types-of-data-objects-in-c/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 09:16:06 +0000</pubDate>
		<dc:creator>zrydento</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[aggregate]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[data objects]]></category>
		<category><![CDATA[fundamental]]></category>
		<category><![CDATA[scalar]]></category>
		<category><![CDATA[structure]]></category>
		<category><![CDATA[typedef]]></category>
		<category><![CDATA[user defined]]></category>

		<guid isPermaLink="false">http://www.zerointellect.com/?p=100</guid>
		<description><![CDATA[<p> </p>
<p>A data object is a block in computer memory that can either contain a single value of a group of values. The value of the data objects can be accessed using a simple variable or another complex expression. Each object has a unique data type which determines how much storage would be allocated in memory. It <p>Continue reading <a href="http://www.zerointellect.com/programming/types-of-data-objects-in-c/">Types of Data Objects in C++</a></p>]]></description>
			<content:encoded><![CDATA[<p> </p>
<p>A data object is a block in computer memory that can either contain a single value of a group of values. The value of the data objects can be accessed using a simple variable or another complex expression. Each object has a unique data type which determines how much storage would be allocated in memory. It is also used in any type checking operations. Both the identifier and data type of an object are established in the object declaration.</p>
<p>Suppose we declare an instance S1 of a class named Student that has variables name, age, class and other similar variables</p>
<blockquote><p><strong>Instance (S1 above) is known as the &#8220;class object&#8221;</strong></p>
<p><strong>Members of the class (age, name, etc) are also called &#8220;member objects&#8221;</strong></p></blockquote>
<p>The collection of all member objects within a class is what constitutes a class object</p>
<p> </p>
<p>There are three major classes of data types</p>
<blockquote><p><strong>Fundamental types vs derived types<br />
Built-in types vs user-defined types<br />
Scalar types vs aggregate types</strong></p></blockquote>
<p><strong> </strong></p>
<p>Fundamental data types are the ones that are &#8220;built-in&#8221; to the language. These already exist and are not created by the user. Examples are integers, floating-point numbers and characters. Derived data types are created from the set of basic types and include arrays, pointers, structures, classes, unions, and enumerations<br />
Built-in data types as made out by their name are those data types that are present and include all of the fundamental types and also include data types that refer to the addresses of basic types, such as arrays and pointers. User-defined types are created by the user from the set of basic types, in typedef, structure, classes, union, and enumeration definitions</p>
<p>Scalar types represent a single data value (like an integer) whereas aggregate types represent multiple values, of the same type or of different types. Scalars data types include the arithmetic types and pointers. Aggregate types include arrays, classes and structures</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zerointellect.com/programming/types-of-data-objects-in-c/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>C++ Logical Negation Operator</title>
		<link>http://www.zerointellect.com/programming/c-logical-negation-operator/</link>
		<comments>http://www.zerointellect.com/programming/c-logical-negation-operator/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 08:48:16 +0000</pubDate>
		<dc:creator>zrydento</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[data type]]></category>
		<category><![CDATA[Logical]]></category>
		<category><![CDATA[Negation]]></category>
		<category><![CDATA[Operator]]></category>
		<category><![CDATA[scalar]]></category>

		<guid isPermaLink="false">http://www.zerointellect.com/?p=85</guid>
		<description><![CDATA[<p> </p>
<p>The logical negation operator ! [exclamation] used in C++ and many other languages. However the return value of the operator is overlooked by many people.</p>
<p> </p>
<p>The syntax of the operator follows is</p>
<p> </p>
<p>! cast-expression</p>
<p> </p>
<p>Where, the cast-expression operand must be of scalar type (returning only a single value, not multiple values like an array)</p>
<p> </p>
<p>The result is of type int <p>Continue reading <a href="http://www.zerointellect.com/programming/c-logical-negation-operator/">C++ Logical Negation Operator</a></p>]]></description>
			<content:encoded><![CDATA[<p> </p>
<p>The logical negation operator <strong>!</strong> [exclamation] used in C++ and many other languages. However the return value of the operator is overlooked by many people.</p>
<p> </p>
<p>The syntax of the operator follows is</p>
<p> </p>
<blockquote><p><strong>! cast-expression</strong></p></blockquote>
<p> </p>
<p>Where, the cast-expression operand must be of scalar type (returning only a single value, not multiple values like an array)</p>
<p> </p>
<p>The result is of type int and is the logical negation of the operand:</p>
<p> </p>
<blockquote><p> <strong>0 if the operand is nonzero</strong></p>
<p><strong> 1 if the operand is zero</strong></p></blockquote>
<p> </p>
<p>To demonstrate the usage of the Logical Negation Operator, the simple program below was written</p>
<p> </p>
<blockquote><p><strong># include &lt;iostream.h&gt;</strong></p>
<p><strong># include &lt;conio.h&gt;</strong></p>
<p><strong> </strong></p>
<p><strong>void main()</strong></p>
<p><strong>{</strong></p>
<p><strong>   clrscr();</strong></p>
<p><strong> </strong></p>
<p><strong>   cout&lt;&lt;&#8221;\nThe expression !0 equals : &#8220;&lt;&lt;!0;</strong></p>
<p><strong>   cout&lt;&lt;&#8221;\nThe expression !0.7 equals : &#8220;&lt;&lt;!0.54;</strong></p>
<p><strong>   cout&lt;&lt;&#8221;\nThe expression !4 equals : &#8220;&lt;&lt;!4;</strong></p>
<p><strong>   cout&lt;&lt;&#8221;\nThe expression !-4 equals : &#8220;&lt;&lt;!-4;</strong></p>
<p><strong> </strong></p>
<p><strong>   getch();</strong></p>
<p><strong>}</strong></p></blockquote>
<p> </p>
<p> The output of the program is an integer value as expected, the negation of the value 0 (Zero) is equal to 1 and the negation operator applied anything else is equal to 0 (Zero)</p>
<p> </p>
<blockquote><p> <strong>The expression !0 equals : 1</strong></p>
<p><strong>The expression !0.7 equals : 0</strong></p>
<p><strong>The expression !4 equals : 0</strong></p>
<p><strong>The expression !-4 equals : 0</strong></p></blockquote>
<p> </p>
<p> To summarize, the things to note are that the return type of the operator is int (integer) and the cast-expression operand must be of scalar type</p>
<p> </p>
<p>Happy Coding</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zerointellect.com/programming/c-logical-negation-operator/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Exceeding the range of data types in C++</title>
		<link>http://www.zerointellect.com/programming/exceeding-the-range-of-data-types-in-c/</link>
		<comments>http://www.zerointellect.com/programming/exceeding-the-range-of-data-types-in-c/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 10:20:37 +0000</pubDate>
		<dc:creator>zrydento</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[borland]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[data types]]></category>
		<category><![CDATA[exceed]]></category>
		<category><![CDATA[int]]></category>
		<category><![CDATA[integer]]></category>
		<category><![CDATA[range]]></category>
		<category><![CDATA[Turbo C++]]></category>
		<category><![CDATA[variable]]></category>

		<guid isPermaLink="false">http://www.zerointellect.com/?p=33</guid>
		<description><![CDATA[<p> </p>
<p>My friend recently gave his C++ oral examination and one of the questions asked by the invigilators was regarding incrementing a variable after it has been set to the maximum value in its range</p>
<p>To be specific, in his case the invigilator asked him the output of a variable of type int if initialized to 32765 and <p>Continue reading <a href="http://www.zerointellect.com/programming/exceeding-the-range-of-data-types-in-c/">Exceeding the range of data types in C++</a></p>]]></description>
			<content:encoded><![CDATA[<p> </p>
<p>My friend recently gave his C++ oral examination and one of the questions asked by the invigilators was regarding incrementing a variable after it has been set to the maximum value in its range</p>
<p>To be specific, in his case the invigilator asked him the output of a variable of type int if initialized to 32765 and then incremented by 1</p>
<p> </p>
<p><strong>Sample Code</strong></p>
<p> </p>
<blockquote><p><strong>int i = 32765;</strong></p>
<p><strong>i++;</strong></p>
<p><strong>cout&lt;&lt;i;</strong></p></blockquote>
<p> </p>
<p><strong>Question:</strong> What is the output value of i ?</p>
<p> </p>
<p>Now as we know the range for an integer in C++ is from -32,768 to 32,767 or from 0 to 65535</p>
<p> </p>
<p>As per the official documentation in the Turbo C++ compiler</p>
<p> </p>
<blockquote><p><strong>Integer data type</strong></p>
<p><strong>Variables of type int are one word in length. They can be signed (default) or unsigned, which means they have a range of -32,768 to 32,767 and 0 to 65,535, respectively</strong></p></blockquote>
<p> </p>
<p>To demonstrate and verify the actual output, I quickly coded the program below</p>
<p> </p>
<blockquote><p><strong># include &lt;iostream.h&gt;</strong></p>
<p><strong># include &lt;conio.h&gt;</strong></p>
<p><strong> </strong></p>
<p><strong>void main()</strong></p>
<p><strong>{</strong></p>
<p><strong>   clrscr();</strong></p>
<p><strong> </strong></p>
<p><strong>   int i = 32765;</strong></p>
<p><strong> </strong></p>
<p><strong>   for(int j=5;j&lt;10;i++)</strong></p>
<p><strong>   {</strong></p>
<p><strong>         j++;</strong></p>
<p><strong>         cout&lt;&lt;i&lt;&lt;&#8221;\n&#8221;;</strong></p>
<p><strong>   }</strong></p>
<p><strong>   getch();</strong></p>
<p><strong>}</strong></p></blockquote>
<p> </p>
<p>A screenshot of the output of the sample above is as under</p>
<p> </p>
<p style="text-align: center"> <img class="aligncenter" src="http://www.zerointellect.com/uploads/0000001-output.png" alt="" width="500" height="258" /> </p>
<p> </p>
<p>This brings us to the conclusion that the variable is incremented until the maximum value of its range (32,767) and is then reinitialized back (-32,768) to the beginning of the range automatically in a circular fashion</p>
<p> </p>
<p style="text-align: center"><img class=" aligncenter" src="http://www.zerointellect.com/uploads/0000001-diagram.png" alt="Incrementing Integer Flow" width="450" height="150" /></p>
<p> </p>
<p>The diagram above gives a graphical representation of what happens when an integer is incremented after being set to the maximum value in its range</p>
<p> </p>
<p>Happy Coding</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zerointellect.com/programming/exceeding-the-range-of-data-types-in-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

