<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8999922090094507351</id><updated>2024-09-15T16:34:11.465-07:00</updated><category term="cprogramming"/><category term="c++programs"/><title type='text'>C &amp;amp; C++ Programs with output  free</title><subtitle type='html'>Programmers Can Get Actual Running Code Here!!&#xa;Happy Coding!!</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>87</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-1222780551228921118</id><published>2013-02-05T08:58:00.002-08:00</published><updated>2013-02-09T18:26:28.498-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cprogramming"/><title type='text'>string length</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h1 class=&quot;title&quot;&gt;
String length&lt;/h1&gt;
&lt;div class=&quot;meta&quot;&gt;
&lt;/div&gt;
This program prints length of string, for example consider the  string &quot;c programming&quot; it&#39;s length is 13. Null character is not counted  when calculating string length. To find string length we use strlen  function of string.h.&lt;br /&gt;
&lt;h2&gt;
C program to find string length&lt;/h2&gt;
&lt;div class=&quot;geshifilter&quot;&gt;
&lt;div class=&quot;prettyprint&quot;&gt;
&lt;pre class=&quot;c geshifilter-c &quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include&amp;lt;string.h&amp;gt;&lt;/span&gt;
&amp;nbsp;
main&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt; a&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; length&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Enter a string to calculate it&#39;s length&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;gets&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;a&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   length &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw3&quot;&gt;strlen&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;a&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Length of entered string is = %d&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;length&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
You can also find string length using pointer or without strlen function. Following program shows how to achieve this.&lt;br /&gt;
&lt;h2&gt;
C program to find string length without strlen&lt;/h2&gt;
C program to find length of a string using pointers.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;geshifilter&quot;&gt;
&lt;pre class=&quot;c geshifilter-c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&amp;nbsp;
main&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt; array&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;pointer&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; length &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Enter a string&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;gets&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;array&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   pointer &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; array&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;pointer&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;length&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
      length&lt;span class=&quot;sy0&quot;&gt;++;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Length of entered string = %d&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;length&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2&gt;
Function to find string length&lt;/h2&gt;
&lt;div class=&quot;geshifilter&quot;&gt;
&lt;pre class=&quot;c geshifilter-c&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; string_length&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;s&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; c &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;s&lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt;c&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
      c&lt;span class=&quot;sy0&quot;&gt;++;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; c&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/1222780551228921118/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2013/02/string-length.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/1222780551228921118'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/1222780551228921118'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2013/02/string-length.html' title='string length'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-480195999165549153</id><published>2012-06-09T04:09:00.000-07:00</published><updated>2012-06-09T04:09:52.699-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cprogramming"/><title type='text'>c program for to add 2 matrix</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;h1 class=&quot;title&quot;&gt;c program to add two matrix&lt;/h1&gt;&lt;div class=&quot;clearfix&quot; id=&quot;content&quot;&gt;&lt;div class=&quot;node clearfix node-page node-full published not-promoted not-sticky without-photo&quot; id=&quot;node-90&quot;&gt;&lt;div class=&quot;meta&quot;&gt;&lt;/div&gt;&lt;div class=&quot;content clearfix&quot;&gt;This c program add two matrices i.e. compute the sum of two  matrices and then print it. Firstly user will be asked to enter the  order of matrix ( number of rows and columns ) and then two matrices.  For example if the user entered order as 2, 2 i.e. two rows and two  columns and matrices as&lt;br /&gt;
First Matrix :-&lt;br /&gt;
1 2&lt;br /&gt;
3 4&lt;br /&gt;
Second matrix :-&lt;br /&gt;
4 5&lt;br /&gt;
-1 5&lt;br /&gt;
then output of the program ( sum of First and Second matrix ) will be&lt;br /&gt;
5 7&lt;br /&gt;
2 9&lt;br /&gt;
&lt;h2&gt;C programming code&lt;/h2&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;c geshifilter-c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&amp;nbsp;
main&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; m&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; n&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; c&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; d&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; first&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; second&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; sum&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Enter the number of rows and columns of matrix &quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d%d&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;m&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;n&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Enter the elements of first matrix&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt; c &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; c &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt; m &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; c&lt;span class=&quot;sy0&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt; d &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; d &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt; n &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; d&lt;span class=&quot;sy0&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
         &lt;span class=&quot;kw3&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;first&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;c&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;d&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Enter the elements of second matrix&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt; c &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; c &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt; m &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; c&lt;span class=&quot;sy0&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt; d &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; d &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt; n &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; d&lt;span class=&quot;sy0&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;kw3&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;second&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;c&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;d&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt; c &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; c &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt; m &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; c&lt;span class=&quot;sy0&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt; d &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; d &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt; n &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; d&lt;span class=&quot;sy0&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
         sum&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;c&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;d&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; first&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;c&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;d&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt; second&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;c&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;d&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Sum of entered matrices:-&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt; c &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; c &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt; m &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; c&lt;span class=&quot;sy0&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
   &lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt; d &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; d &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt; n &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; d&lt;span class=&quot;sy0&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
         &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d&lt;span class=&quot;es1&quot;&gt;\t&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; sum&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;c&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;d&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
      &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.programmingsimplified.com/toolsArea/executable/add%20two%20matrix.EXE&quot;&gt;Add matrices&lt;/a&gt; program. Output of program:&lt;br /&gt;
&lt;img alt=&quot;add matrices&quot; src=&quot;http://www.programmingsimplified.com/toolsArea/images/add%20two%20matrix.png&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/480195999165549153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/06/c-program-for-to-add-2-matrix.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/480195999165549153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/480195999165549153'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/06/c-program-for-to-add-2-matrix.html' title='c program for to add 2 matrix'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-2396731424844562963</id><published>2012-05-28T19:02:00.002-07:00</published><updated>2012-05-28T19:02:31.930-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>C++ Lists: A Simple List Of Items</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;table border=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td width=&quot;100%&quot;&gt;&lt;div class=&quot;headtitle&quot;&gt;Header File: List.h&lt;/div&gt;&lt;/td&gt;    &lt;/tr&gt;
&lt;tr&gt;      &lt;td width=&quot;100%&quot;&gt;        &lt;pre&gt;//---------------------------------------------------------------------------

#ifndef ListH

#define ListH

//---------------------------------------------------------------------------

const int MaxItems = 100;

typedef double ItemType;



class FList

{

public:

    FList();

    virtual ~FList();

    int Count() const;

    bool Add(const ItemType NewItem);

    ItemType Retrieve(const int Pos);

    bool Delete(const int Pos);



private:

    int Counter;

    ItemType Item[MaxItems];

    const Index(const int Pos) const;

};

//---------------------------------------------------------------------------

#endif&lt;/pre&gt;&lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;table border=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;      &lt;td width=&quot;100%&quot;&gt;        &lt;div class=&quot;headtitle&quot;&gt;Source File: List.cpp&lt;/div&gt;&lt;/td&gt;    &lt;/tr&gt;
&lt;tr&gt;      &lt;td width=&quot;100%&quot;&gt;        &lt;pre&gt;//---------------------------------------------------------------------------

#pragma hdrstop



#include &quot;List.h&quot;

//---------------------------------------------------------------------------

#pragma package(smart_init)

FList::FList()

    : Counter(0)

{

}

//---------------------------------------------------------------------------

FList::~FList()

{

}//---------------------------------------------------------------------------

int FList::Count() const

{

    return Counter;

}

//---------------------------------------------------------------------------

const FList::Index(const int Pos) const

{

    return Pos-1;

}

//---------------------------------------------------------------------------

bool FList::Add(const ItemType NewItem)

{

    if( (Counter &amp;lt; 0) || (Counter &amp;gt; MaxItems) )

        return false;

    else

    {

        Item[Counter] = NewItem;

        Counter++;

        return true;

    }

}

//---------------------------------------------------------------------------

ItemType FList::Retrieve(const int Pos)

{

    if( (Pos &amp;lt; 0) || (Pos &amp;gt; Counter) )

        return 0;

    else

        return Item[Pos];

}

//---------------------------------------------------------------------------

bool FList::Delete(const int Pos)

{

    if( (Pos &amp;lt; 0) || (Pos &amp;gt; Counter) )

        return false;

    else

    {

        for(int i = Pos+1; i &amp;lt;= Counter; i++)

            Item[Index(i-1)] = Item[Index(i)];

        Counter--;

        return true;

    }

}

//---------------------------------------------------------------------------&lt;/pre&gt;&lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;table border=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;      &lt;td width=&quot;100%&quot;&gt;        &lt;div class=&quot;headtitle&quot;&gt;Source File: Main.cpp&lt;/div&gt;&lt;/td&gt;    &lt;/tr&gt;
&lt;tr&gt;      &lt;td width=&quot;100%&quot;&gt;        &lt;pre&gt;//---------------------------------------------------------------------------

#include &amp;lt;iostream&amp;gt;

#include &amp;lt;conio&amp;gt;

using namespace std;

#pragma hdrstop

#include &quot;List.h&quot;

//---------------------------------------------------------------------------



#pragma argsused

int main(int argc, char* argv[])

{

    FList List;



    List.Add(1240.42);

    List.Add(283.15);

    List.Add(42.48);

    List.Add(582.12);

    List.Add(60.14);

    List.Add(8022.28);



    cout &amp;lt;&amp;lt; &quot;List of items&quot;;

    for(int i = 0; i &amp;lt; List.Count(); i++)

        cout &amp;lt;&amp;lt; &quot;\nItem No.&quot; &amp;lt;&amp;lt; i + 1 &amp;lt;&amp;lt; &quot;: &quot; &amp;lt;&amp;lt; List.Retrieve(i);

    cout &amp;lt;&amp;lt; &quot;\nNumber of items: &quot; &amp;lt;&amp;lt; List.Count() &amp;lt;&amp;lt; &quot; items\n\n&quot;;



    List.Delete(5);

    List.Delete(2);

    cout &amp;lt;&amp;lt; &quot;List of items&quot;;

    for(int i = 0; i &amp;lt; List.Count(); i++)

        cout &amp;lt;&amp;lt; &quot;\nItem No.&quot; &amp;lt;&amp;lt; i + 1 &amp;lt;&amp;lt; &quot;: &quot; &amp;lt;&amp;lt; List.Retrieve(i);

    cout &amp;lt;&amp;lt; &quot;\nNumber of items: &quot; &amp;lt;&amp;lt; List.Count() &amp;lt;&amp;lt; &quot; items\n\n&quot;;



    cout &amp;lt;&amp;lt; &quot;Press any key to continue...&quot;;

    getch();

    return 0;

}

//---------------------------------------------------------------------------&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/2396731424844562963/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-lists-simple-list-of-items.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/2396731424844562963'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/2396731424844562963'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-lists-simple-list-of-items.html' title='C++ Lists: A Simple List Of Items'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-4168160182223260328</id><published>2012-05-28T19:01:00.000-07:00</published><updated>2012-05-28T19:01:41.179-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>Class Inheritance</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;ParaJust&quot;&gt;Inheritance  is the ability for one class to receive      its primary functionality  from another class, also called its base class.&lt;/div&gt;&lt;div class=&quot;ParaJust&quot;&gt;This  example uses a class called Circle so that, given a radius, the program  would      calculate and display the diameter, the circumference, and  the area.&lt;/div&gt;&lt;div class=&quot;ParaJust&quot;&gt;Another class called Sphere is  derived from the Circle      class. This class can supply its own  radius, display the same      pieces of information as the Circle.  Additionally, the Sphere class should      calculate and display the  volume.&lt;/div&gt;&lt;div class=&quot;ParaJust&quot;&gt;This exercise uses different header  and source files.      It uses the following five files: circle.h,  circle.cpp, sphere.h,      sphere.cpp and exo.cpp.&lt;/div&gt;&lt;span style=&quot;color: red;&quot;&gt;Header File: circle.h&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;CodeFormat&quot;&gt;#ifndef CIRCLE_H&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#define CIRCLE_H&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;struct Circle{&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;public:&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Circle();&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;void setRadius(double r);&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double getRadius();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;double Diameter();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;double Circumference();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;double Area();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;void Display();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;protected:&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double Radius;private:&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;};&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#endif&lt;/pre&gt;&lt;span style=&quot;color: red;&quot;&gt;Source File: circle.cpp&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;CodeFormat&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#include &quot;circle.h&quot;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;const double PI = 3.14159;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Circle::Circle()&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Radius = 0;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;void Circle::setRadius(double r)&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{ Radius = r &amp;lt;= 0 ? 1 : r;}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double Circle::getRadius()&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{ return Radius;}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double Circle::Diameter(){&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;return Radius * 2;}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double Circle::Circumference()&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{ return Diameter() * PI;}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double Circle::Area(){&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;return Radius * Radius * PI;}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;void Circle::Display()&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{ cout &amp;lt;&amp;lt; &quot;\nCircle Properties&quot;;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\nRadius        = &quot; &amp;lt;&amp;lt; getRadius();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\nDiameter      = &quot; &amp;lt;&amp;lt; Diameter();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\nCircumference = &quot; &amp;lt;&amp;lt; Circumference();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\nArea          = &quot; &amp;lt;&amp;lt; Area() &amp;lt;&amp;lt; &quot;\n&quot;;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}&lt;/pre&gt;&lt;span style=&quot;color: red;&quot;&gt;Header File: sphere.h&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;CodeFormat&quot;&gt;#ifndef SPHERE_H&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#define SPHERE_H&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;struct Sphere : public Circle&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{public:&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double Volume();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;void Show();private:};&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#endif&lt;/pre&gt;&lt;span style=&quot;color: red;&quot;&gt;Source File: sphere.cpp&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;CodeFormat&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#include &quot;circle.h&quot;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#include &quot;sphere.h&quot;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;const double PI = 3.14159;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double Sphere::Volume()&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{ return Radius * Radius * Radius * PI * 4 / 3;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}void Sphere::Show(){&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\nCircle Properties&quot;;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\nRadius        = &quot; &amp;lt;&amp;lt; getRadius();&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\nDiameter      = &quot; &amp;lt;&amp;lt; Diameter();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\nCircumference = &quot; &amp;lt;&amp;lt; Circumference();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\nArea          = &quot; &amp;lt;&amp;lt; Area();&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\nVolume        = &quot; &amp;lt;&amp;lt; Volume() &amp;lt;&amp;lt; &quot;\n\n&quot;;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}&lt;/pre&gt;&lt;span style=&quot;color: red;&quot;&gt;Main File: exo.cpp&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;CodeFormat&quot;&gt;#include &quot;circle.h&quot;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#include &quot;sphere.h&quot;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;void main(){&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Circle circle;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;// Displaying a circle using the default value of the radius&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;circle.Display();&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Circle circ;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;// A circle with a value supplied for the radius&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;circ.setRadius(12.50); circ.Display(); Sphere sphere;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;// A sphere that has its own radius, using the functions&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;sphere.setRadius(8.95); // of the base class&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;sphere.Show();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/4168160182223260328/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/class-inheritance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/4168160182223260328'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/4168160182223260328'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/class-inheritance.html' title='Class Inheritance'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-9177611657858816287</id><published>2012-05-28T18:57:00.002-07:00</published><updated>2012-05-28T18:57:48.565-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>String Entering Example</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;ParaJust&quot; style=&quot;color: black;&quot;&gt;This example shows how to perform data entry on        strings. The strings are simple array of characters and they are declared        as member variables of a class. The class provides accessory methods for        each member variable.&lt;/div&gt;&lt;div style=&quot;color: black;&quot;&gt;Header File: Person.h  &lt;/div&gt;&lt;pre style=&quot;color: black;&quot;&gt;//---------------------------------------------------------------------------
#ifndef PersonH
#define PersonH

//---------------------------------------------------------------------------
class TPerson
{
private:
    char* FirstName;
    char* LastName;
    char* Address;
    char* City;
     char* State;
    long  ZIPCode;

public:
    void  setFirstName(const char *FN);
    char* getFirstName() const { return FirstName; }
    void  setLastName(const char *LN);
    char* getLastName() const { return LastName; }
    char* FullName() const;
    void  setAddress(const char *Adr);
    char* getAddress() const { return Address; }
    void  setCity(const char *CT);
    char* getCity() const { return City; }
    void  setState(const char *St);
    char* getState() const { return State; }
    void  setZIPCode(const long ZIP);
    long  getZIPCode() const { return ZIPCode; }

    TPerson();
    TPerson(char *FName, char *LName, char *Adr,
            char *Ct, char *St, long  ZIP);
    TPerson(const TPerson &amp;amp;Pers);
    TPerson(char * FName, char * LName);
    virtual ~TPerson();
};
//---------------------------------------------------------------------------
#endif&lt;/pre&gt;&lt;div style=&quot;color: black;&quot;&gt;Source File: Person.cppfont&amp;gt;  &lt;/div&gt;&lt;pre style=&quot;color: black;&quot;&gt;//---------------------------------------------------------------------------

#i#include &amp;lt;iostream&amp;gt;
using namespace std;

#pragma hdrstop

#include &quot;Person.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)

//---------------------------------------------------------------------------&lt;/pre&gt;&lt;pre style=&quot;color: black;&quot;&gt;char *__fastcall TPerson::FullName() const
{
    char *FName = new char[40];
    strcpy(FName, FirstName);
    strcat(FName, &quot; &quot;);
    strcat(FName, LastName);

    return FName;
}
//---------------------------------------------------------------------------
__fastcall TPerson::TPerson()
    : ZIPCode(0)
{
    //TODO: Add your source code here  
    FirstName = new char[20];
    strcpy(FirstName, &quot;John&quot;);
    LastName  = new char[20];
    strcpy(LastName, &quot;Doe&quot;);
    Address   = new char[40];
    strcpy(Address, &quot;123 Main Street Apt A&quot;);
    City      = new char[32];
    strcpy(City, &quot;Great City&quot;);
    State     = new char[30];
    strcpy(State, &quot;Our State&quot;);
}
//---------------------------------------------------------------------------
__fastcall TPerson::TPerson(char * FName, char * LName)
    : ZIPCode(0)
{
    //TODO: Add your source code here
    FirstName = new char[strlen(FName) + 1];
    strcpy(FirstName, FName);
    LastName  = new char[strlen(LName) + 1];
    strcpy(LastName, LName);
    Address   = new char[40];
    strcpy(Address, &quot;123 Main Street Apt A&quot;);
    City      = new char[32];
    strcpy(City, &quot;Great City&quot;);
    State     = new char[30];
    strcpy(State, &quot;Our State&quot;);
} 
//---------------------------------------------------------------------------
__fastcall TPerson::TPerson(char *FName, char *LName, char *Adr,
                       char *Ct, char *St, long  ZIP)
    : ZIPCode(ZIP)
{                          
    //TODO: Add your source code here  
    FirstName = new char[strlen(FName) + 1];
    strcpy(FirstName, FName);
    LastName  = new char[strlen(LName) + 1];
    strcpy(LastName, LName);
    Address   = new char[40];
    strcpy(Address, Adr);
    City      = new char[32];
    strcpy(City, Ct);
    State     = new char[30];
    strcpy(State, St);
}
//---------------------------------------------------------------------------
__fastcall TPerson::TPerson(const TPerson &amp;amp;Pers)
    : ZIPCode(Pers.ZIPCode)
{              
    //TODO: Add your source code here
    FirstName = new char[strlen(Pers.FirstName) + 1];
    strcpy(FirstName, Pers.FirstName);
    LastName  = new char[strlen(Pers.LastName) + 1];
    strcpy(LastName, Pers.LastName);
    Address   = new char[strlen(Pers.Address) + 1];
    strcpy(Address, Pers.Address);
    City      = new char[strlen(Pers.City) + 1];
    strcpy(City, Pers.City);
    State     = new char[strlen(Pers.State) + 1];
    strcpy(State, Pers.State);
}
//---------------------------------------------------------------------------
void __fastcall TPerson::setFirstName(const char *FN)
{
    strcpy(FirstName, FN);
}
//---------------------------------------------------------------------------
void __fastcall TPerson::setLastName(const char *LN)
{
    strcpy(LastName, LN);
}
//---------------------------------------------------------------------------
void __fastcall TPerson::setAddress(const char *Adr)
{
    strcpy(Address, Adr);
}
//---------------------------------------------------------------------------
void  __fastcall TPerson::setCity(const char *CT)
{
    strcpy(City, CT);
}
//---------------------------------------------------------------------------
void  __fastcall TPerson::setState(const char *St)
{
    strcpy(State, St);
}
//---------------------------------------------------------------------------
void  __fastcall TPerson::setZIPCode(const long ZIP)
{
    ZIPCode = ZIP;
}
//---------------------------------------------------------------------------
__fastcall TPerson::~TPerson()
{
    //TODO: Add your source code here
    delete [] FirstName;
    delete [] LastName;
    delete [] Address;
    delete [] City;
    delete [] State;
}
//---------------------------------------------------------------------------&lt;/pre&gt;&lt;div style=&quot;color: black;&quot;&gt;    &lt;/div&gt;Main File: Main.cpp  &lt;br /&gt;
&lt;pre&gt;////---------------------------------------------------------------------------
#include &amp;lt;iostream&amp;gt;
using namespace std;

#agma hdrstop

#i#include &quot;Person.h&quot;
//---------------------------------------------------------------------------

#pragma argsused

TPerson ProcessRegistration();
void DisplayInformation(const TPerson&amp;amp;);
//---------------------------------------------------------------------------
int main(int argc, char* argv[])
{
    TPerson Employee = ProcessRegistration();
    DisplayInformation(Employee);

    return 0;
}
//---------------------------------------------------------------------------
TPerson ProcessRegistration()
{
    char FName[12], LName[12];
    char Addr[40], CT[32], St[30];
    long ZC;

    cout &amp;lt;&amp;lt; &quot;Enter personal information\n&quot;;
    cout &amp;lt;&amp;lt; &quot;First Name: &quot;; cin &amp;gt;&amp;gt; FName;
    cout &amp;lt;&amp;lt; &quot;Last Name:  &quot;; cin &amp;gt;&amp;gt; LName;
    cout &amp;lt;&amp;lt; &quot;Address:    &quot;; cin &amp;gt;&amp;gt; ws;
    cin.getline(Addr, 40);
    cout &amp;lt;&amp;lt; &quot;City:       &quot;;
    cin.getline(CT, 32);
    cout &amp;lt;&amp;lt; &quot;State:      &quot;;
    cin.getline(St, 30);
    cout &amp;lt;&amp;lt; &quot;Zip Code:   &quot;; cin &amp;gt;&amp;gt; ZC;

    TPerson Pers(FName, LName, Addr, CT, St, ZC);
    return Pers;
}
//---------------------------------------------------------------------------
void DisplayInformation(const TPerson&amp;amp; Pers)
{
    cout &amp;lt;&amp;lt; &quot;\nEmployee Identification&quot;;
    cout &amp;lt;&amp;lt; &quot;\nFull Name: &quot; &amp;lt;&amp;lt; Pers.FullName();
    cout &amp;lt;&amp;lt; &quot;\nAddress:   &quot; &amp;lt;&amp;lt; Pers.getAddress();
    cout &amp;lt;&amp;lt; &quot;\nCity:      &quot; &amp;lt;&amp;lt; Pers.getCity() &amp;lt;&amp;lt; &quot;, &quot;
         &amp;lt;&amp;lt; Pers.getState() &amp;lt;&amp;lt; &quot; &quot; &amp;lt;&amp;lt; Pers.getZIPCode();
}
//---------------------------------------------------------------------------&lt;/pre&gt;&lt;br /&gt;
&lt;div style=&quot;color: black;&quot;&gt;Here is an example of running the program:&lt;/div&gt;&lt;pre&gt;EnEnter personal information
First Name: Jeremy
Last Name:  Nguyen
Address:    1466 16th Street #B
City:       WashingtonState:      DC
ZZip Code:   20004

Employee Identification
Full Name: Jeremy Nguyenddress:   1466 16th Street #B
City:      Washington, DC 20004&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/9177611657858816287/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/string-entering-example.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/9177611657858816287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/9177611657858816287'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/string-entering-example.html' title='String Entering Example'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-4379225094257230401</id><published>2012-05-28T18:56:00.000-07:00</published><updated>2012-05-28T18:56:26.871-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>This example shows to nest an object in another&#39;s body</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;ParaJust&quot;&gt;The C++ language allows you to create a class inside        of another. This technique is referred to as nesting. At the time of this        writing, nesting a class B inside of a class A doesn&#39;t give any access        privilege of class A&#39; member variables and methods to class B. Therefore,        there is no major advantage to do it, only a matter of convenience and        probably personal preference and opinion. It is said that the next C++        standard will allow a nested class B to have access to the private member        variables and methods of the nesting class A.&lt;/div&gt;&lt;div class=&quot;ParaJust&quot;&gt;(As you can see, this program was created in Borland        C++ Builder. If you are using another compiler, remove the #pragma and        probably the conio lines)&lt;/div&gt;&lt;table border=&quot;0&quot; style=&quot;width: 560px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;          &lt;td width=&quot;100%&quot;&gt;&lt;pre&gt;//---------------------------------------------------------------------------

#include &amp;lt;iostream&amp;gt;

#include &amp;lt;conio&amp;gt;

using namespace std;

#pragma hdrstop



//---------------------------------------------------------------------------



#pragma argsused

const int Maximum = 100;

//---------------------------------------------------------------------------

class TListOfStudents

{

public:

    class TStudent

    {

    private:

        string FullName;

        int    Age;

        char   Gender;

    public:

        void   setFullName(const string Name) { FullName = Name; }

        string getFullName() const { return FullName; }

        void   setAge(const int a) { Age = a; }

        int    getAge() const { return Age; }

        void   setGender(const char g) { Gender = g; }

        char   getGender() const { return Gender; }

        TStudent();

        TStudent(string FName, int a, char g);

        inline virtual ~TStudent() {}

    };

private:

    TStudent Item[Maximum];



public:

    TListOfStudents() : Count(0){}

    inline ~TListOfStudents() {}

    void Add(const TStudent&amp;amp; d);

    TStudent Retrieve(const int n);

    int Count;

};

//---------------------------------------------------------------------------

TListOfStudents::TStudent::TStudent()

{

    FullName = &quot;&quot;;

    Age      = 0.00;

    Gender   = &#39;M&#39;;

}

//---------------------------------------------------------------------------

TListOfStudents::TStudent::TStudent(string FName, int a, char g)

{

    FullName = FName;

    Age      = a;

    Gender   = g;

}

//---------------------------------------------------------------------------

void __fastcall TListOfStudents::Add(const TStudent&amp;amp; d)

{

    if( Count &amp;lt; Maximum )

    {

 Item[Count] = d;

 Count++;

    }

}

//---------------------------------------------------------------------------

TListOfStudents::TStudent TListOfStudents::Retrieve(const int n)

{

    return Item[n];

}

//---------------------------------------------------------------------------

void __fastcall DisplayList(TListOfStudents &amp;amp;List);

void __fastcall CreateList(TListOfStudents &amp;amp;List);

//---------------------------------------------------------------------------

int main(int argc, char* argv[])

{

    TListOfStudents ListOfItems;



    CreateList(ListOfItems);

 

    DisplayList(ListOfItems);



    return 0;

}

//---------------------------------------------------------------------------

void CreateList(TListOfStudents &amp;amp;ListOfItems)

{

 TListOfStudents::TStudent Pupil;



 Pupil.setFullName(&quot;Harry Seamen&quot;);

 Pupil.setAge(12);

 Pupil.setGender(&#39;M&#39;);

 ListOfItems.Add(Pupil);



 Pupil.setFullName(&quot;Hermine Grand&quot;);

 Pupil.setAge(14);

 Pupil.setGender(&#39;F&#39;);

 ListOfItems.Add(Pupil);



 Pupil.setFullName(&quot;Ronald Hannah&quot;);

 Pupil.setAge(18);

 Pupil.setGender(&#39;M&#39;);

 ListOfItems.Add(Pupil);



 Pupil.setFullName(&quot;Johnny Hancock&quot;);

 Pupil.setAge(16);

 Pupil.setGender(&#39;M&#39;);

 ListOfItems.Add(Pupil);



}

//---------------------------------------------------------------------------

void DisplayList(TListOfStudents &amp;amp;ListOfItems)

{

 cout &amp;lt;&amp;lt; &quot;Full Name\tAge\tGender&quot;;

 string Gender[] = { &quot;Male&quot;, &quot;Female&quot;, &quot;Unknown&quot; };



 for(int i = 0; i &amp;lt; ListOfItems.Count; i++)

 {

  cout &amp;lt;&amp;lt; &quot;\n&quot; &amp;lt;&amp;lt; ListOfItems.Retrieve(i).getFullName()

       &amp;lt;&amp;lt; &quot;\t&quot; &amp;lt;&amp;lt; ListOfItems.Retrieve(i).getAge()

       &amp;lt;&amp;lt; &quot;\t&quot;;

  switch(ListOfItems.Retrieve(i).getGender())

  {

  case &#39;m&#39;:

  case &#39;M&#39;:

   cout &amp;lt;&amp;lt; Gender[0];

   break;

  case &#39;f&#39;:

  case &#39;F&#39;:

   cout &amp;lt;&amp;lt; Gender[1];

   break;

  default:

   cout &amp;lt;&amp;lt; Gender[2];

  }

 }

}

//---------------------------------------------------------------------------&lt;/pre&gt;&lt;/td&gt;        &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;Here is an example of running the program:&lt;br /&gt;
&lt;pre&gt;Full Name       Age     Gender

Harry Seamen    12      Male

Hermine Grand   14      Female

Ronald Hannah   18      Male

Johnny Hancock  16      Male&lt;/pre&gt;&lt;ins style=&quot;border: none; display: inline-table; height: 90px; margin: 0; padding: 0; position: relative; visibility: visible; width: 728px;&quot;&gt;&lt;/ins&gt;&lt;br /&gt;
&lt;ins id=&quot;aswift_1_anchor&quot; style=&quot;border: none; display: block; height: 90px; margin: 0; padding: 0; position: relative; visibility: visible; width: 728px;&quot;&gt;&lt;/ins&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/4379225094257230401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/this-example-shows-to-nest-object-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/4379225094257230401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/4379225094257230401'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/this-example-shows-to-nest-object-in.html' title='This example shows to nest an object in another&#39;s body'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-3221067469682413453</id><published>2012-05-28T18:55:00.002-07:00</published><updated>2012-05-28T18:55:25.522-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>This example uses anonymous Objects, that is, objects that don&#39;t have a name</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;ParaJust&quot;&gt;An anonymous class is one that doesn&#39;t have a name. In        the following example, both structures inside the TRectangle union are        anonymous classes:&lt;/div&gt;&lt;table border=&quot;0&quot; style=&quot;width: 560px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;          &lt;td width=&quot;100%&quot;&gt;            &lt;pre&gt;//---------------------------------------------------------------------------

#include &amp;lt;iostream&amp;gt;

#include &amp;lt;conio&amp;gt;

using namespace std;

#pragma hdrstop



//---------------------------------------------------------------------------

#pragma argsused

// This rectangle can be identified by EITHER its location OR its dimensions

union TRectangle

{

    struct // Location

    {

        int x1;

        int y1;

        int x2;

        int y2;

    };

    struct // Dimensions

    {

        double Length;

        double Height;

    };

};

//---------------------------------------------------------------------------

int main(int argc, char* argv[])

{

    TRectangle Recto;

    char Choice;



    cout &amp;lt;&amp;lt; &quot;You want to identify your rectangle by &quot;

         &amp;lt;&amp;lt; &quot;its location or its dimensions?&quot;;

    cout &amp;lt;&amp;lt; &quot;\n1 - Location&quot;;

    cout &amp;lt;&amp;lt; &quot;\n2 - Dimension&quot;;

    cout &amp;lt;&amp;lt; &quot;\nEnter your choice: &quot;;

    cin &amp;gt;&amp;gt; Choice;



    if( Choice == &#39;1&#39; )

    {

        cout &amp;lt;&amp;lt; &quot;\nEnter the location of the rectangle on a &quot;

             &amp;lt;&amp;lt; &quot;Cartesian coordinate system\n&quot;;

        cout &amp;lt;&amp;lt; &quot;First point\n&quot;;

        cout &amp;lt;&amp;lt; &quot;X coordinate: &quot;; cin &amp;gt;&amp;gt; Recto.x1;

        cout &amp;lt;&amp;lt; &quot;Y coordinate: &quot;; cin &amp;gt;&amp;gt; Recto.y1;

        cout &amp;lt;&amp;lt; &quot;Second point\n&quot;;

        cout &amp;lt;&amp;lt; &quot;X coordinate: &quot;; cin &amp;gt;&amp;gt; Recto.x2;

        cout &amp;lt;&amp;lt; &quot;Y coordinate: &quot;; cin &amp;gt;&amp;gt; Recto.y2;

        cout &amp;lt;&amp;lt; &quot;\nThe rectangle spans from A(&quot;

             &amp;lt;&amp;lt; Recto.x1 &amp;lt;&amp;lt; &quot;, &quot; &amp;lt;&amp;lt; Recto.y1 &amp;lt;&amp;lt; &quot;) to B(&quot;

             &amp;lt;&amp;lt; Recto.x2 &amp;lt;&amp;lt; &quot;, &quot; &amp;lt;&amp;lt; Recto.y2 &amp;lt;&amp;lt; &quot;).\n&quot;;

    }

    else if( Choice == &#39;2&#39; )

    {

        cout &amp;lt;&amp;lt; &quot;Enter the dimensions of the rectangle\n&quot;;

        cout &amp;lt;&amp;lt; &quot;Length: &quot;; cin &amp;gt;&amp;gt; Recto.Length;

        cout &amp;lt;&amp;lt; &quot;Height: &quot;; cin &amp;gt;&amp;gt; Recto.Height;

        cout &amp;lt;&amp;lt; &quot;\nDimensions of the rectangle&quot;;

        cout &amp;lt;&amp;lt; &quot;\nLength: &quot; &amp;lt;&amp;lt; Recto.Length;

        cout &amp;lt;&amp;lt; &quot;\nHeight: &quot; &amp;lt;&amp;lt; Recto.Height &amp;lt;&amp;lt; endl;

    }

    else

        cout &amp;lt;&amp;lt; &quot;\nInvalid Choice&quot;;



    return 0;

}

//---------------------------------------------------------------------------&lt;/pre&gt;&lt;/td&gt;        &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;Here is an example of running the program:&lt;pre&gt;You want to identify your rectangle by its location or its dimensions?

1 - Location

2 - Dimension

Enter your choice: 1



Enter the location of the rectangle on a Cartesian coordinate system

First point

X coordinate: -4

Y coordinate: 2

Second point

X coordinate: 5

Y coordinate: 1



The rectangle spans from A(-4, 2) to B(5, 1).



Press any key to continue...

&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/3221067469682413453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/this-example-uses-anonymous-objects.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/3221067469682413453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/3221067469682413453'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/this-example-uses-anonymous-objects.html' title='This example uses anonymous Objects, that is, objects that don&#39;t have a name'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-1624356530176919273</id><published>2012-05-28T18:53:00.001-07:00</published><updated>2012-05-28T18:53:27.503-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>An object as a member variable of another object</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;ParaJust&quot;&gt;This is an example of one object (the shape class implements a        rectangle) being a member variable of another object (a brick).&lt;/div&gt;&lt;span style=&quot;color: red;&quot;&gt;Header File: shape.h&lt;/span&gt;  &lt;br /&gt;
&lt;pre class=&quot;CodeFormat&quot;&gt;#ifndef _SHAPE_H

#define _SHAPE_H



class FRectangle

{

public:

 FRectangle(double l = 0, double w = 0)

  : Length(l), Width(w) {}

 void setLength(double lgt);

 void setWidth(double wdt);

 double getLength() const;

 double getWidth() const;

 double Perimeter() const;

 double Area() const;

 void Properties();

private:

 double Length;

 double Width;

};



#endif // _SHAPE_H&lt;/pre&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;a class=&quot;kLink&quot; href=&quot;http://www.functionx.com/cpp/examples/classmbr.htm#&quot; id=&quot;KonaLink1&quot; style=&quot;font-family: inherit !important; font-size: inherit !important; font-weight: inherit !important; position: static; text-decoration: underline !important;&quot;&gt;&lt;span style=&quot;color: blue; font-family: inherit; font-size: inherit ! important; font-weight: inherit ! important; position: static;&quot;&gt;&lt;span class=&quot;kLink&quot; style=&quot;color: blue; font-family: inherit; font-size: inherit ! important; font-weight: inherit ! important; position: static;&quot;&gt;Source &lt;/span&gt;&lt;span class=&quot;kLink&quot; style=&quot;color: blue; font-family: inherit; font-size: inherit ! important; font-weight: inherit ! important; position: static;&quot;&gt;File&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;: shape.cpp&lt;/span&gt;  &lt;br /&gt;
&lt;pre class=&quot;CodeFormat&quot;&gt;#include &amp;lt;iostream.h&amp;gt;

#include &quot;shape.h&quot;



void FRectangle::setLength(double lgt)

{

 Length = lgt;

}



void FRectangle::setWidth(double wdt)

{

 Width = wdt;

}



double FRectangle::getLength() const

{

 return Length;

}



double FRectangle::getWidth() const

{

 return Width;

}



double FRectangle::Perimeter() const

{

 return 2 * (Length + Width);

}



double FRectangle::Area() const

{

 return Length * Width;

}



void FRectangle::Properties()

{

 cout &amp;lt;&amp;lt; &quot;\nRectangle characteristics&quot;;

 cout &amp;lt;&amp;lt; &quot;\n\tLength    = &quot; &amp;lt;&amp;lt; Length;

 cout &amp;lt;&amp;lt; &quot;\n\tWidth     = &quot; &amp;lt;&amp;lt; Width;

 cout &amp;lt;&amp;lt; &quot;\n\tPerimeter = &quot; &amp;lt;&amp;lt; Perimeter();

 cout &amp;lt;&amp;lt; &quot;\n\tArea      = &quot; &amp;lt;&amp;lt; Area() &amp;lt;&amp;lt; endl;

}&lt;/pre&gt;&lt;span style=&quot;color: red;&quot;&gt;Header File: brick.h&lt;/span&gt;  &lt;br /&gt;
&lt;pre class=&quot;CodeFormat&quot;&gt;#ifndef BRICK_H_

#define BRICK_H_



#include &quot;shape.h&quot;



class Brick

{

public:

 Brick() {}

 void setThickness(double Tck);

 void setDimensions(double l, double w, double t);

 void setColor(char* clr);

 void setTexture(char* txr);

 char* getColor() const;

 char* getTexture() const;

 double Volume() const;

 void Display();

private:

 FRectangle shape;

 char* Color;

 char* Texture;

 double Thickness;

};



#endif // BRICK_H_&lt;/pre&gt;&lt;span style=&quot;color: red;&quot;&gt;Source File: brick.cpp&lt;/span&gt;  &lt;br /&gt;
&lt;pre class=&quot;CodeFormat&quot;&gt;#include &amp;lt;iostream.h&amp;gt;

#include &quot;brick.h&quot;



void Brick::setThickness(double Tck)

{

 Thickness = Tck;

}



void Brick::setColor(char* clr)

{

 Color = clr;

}



void Brick::setTexture(char* txr)

{

 Texture = txr;

}



void Brick::setDimensions(double l, double w, double t)

{

 shape.setLength(l);

 shape.setWidth(w);

 setThickness(t);

}



char* Brick::getColor() const

{

 return Color;

}



char* Brick::getTexture() const

{

 return Texture;

}



double Brick::Volume() const

{

 return shape.getLength() * shape.getWidth() * Thickness;

}



void Brick::Display()

{

 cout &amp;lt;&amp;lt; &quot;\nBrick characteristics&quot;;

 cout &amp;lt;&amp;lt; &quot;\n\tLength   = &quot; &amp;lt;&amp;lt; shape.getLength();

 cout &amp;lt;&amp;lt; &quot;\n\tWidth    = &quot; &amp;lt;&amp;lt; shape.getWidth();

 cout &amp;lt;&amp;lt; &quot;\n\tArea     = &quot; &amp;lt;&amp;lt; shape.Area();

 cout &amp;lt;&amp;lt; &quot;\n\tVolume   = &quot; &amp;lt;&amp;lt; Volume();

 cout &amp;lt;&amp;lt; &quot;\n\tColor    = &quot; &amp;lt;&amp;lt; getColor();

 cout &amp;lt;&amp;lt; &quot;\n\tTextture = &quot; &amp;lt;&amp;lt; getTexture();

 cout &amp;lt;&amp;lt; endl;

}&lt;/pre&gt;&lt;span style=&quot;color: red;&quot;&gt;Main File: Exo.cpp&lt;/span&gt;  &lt;br /&gt;
&lt;pre class=&quot;CodeFormat&quot;&gt;#include &quot;shape.h&quot;

#include &quot;brick.h&quot;



void main()

{

 Brick brick;



 brick.setDimensions(12.50, 8.75, 5.55);

 brick.setColor(&quot;Bone White&quot;);

 brick.setTexture(&quot;Early Breeze&quot;);



 brick.Display();

}&lt;/pre&gt;Here is an example of running the program:  &lt;pre&gt;Brick characteristics

        Length   = 12.5

        Width    = 8.75

        Area     = 109.375

        Volume   = 607.031

        Color    = Bone White

        Textture = Early Breeze&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/1624356530176919273/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/object-as-member-variable-of-another.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/1624356530176919273'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/1624356530176919273'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/object-as-member-variable-of-another.html' title='An object as a member variable of another object'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-2427605801699405185</id><published>2012-05-28T18:48:00.002-07:00</published><updated>2012-05-28T18:48:37.494-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>An object declared as an array</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This example show how to declare and use an array of an object&lt;br /&gt;
&lt;pre&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

struct Paper
{
public:
    void GetDimensions();
    void Properties();

private:
    double Perimeter() const;
    double Area() const;
    double Height;
    double Width;
};

void Paper::GetDimensions()
{
    cout &amp;lt;&amp;lt; &quot;Enter the dimensions of the label\n&quot;;
    cout &amp;lt;&amp;lt; &quot;Height: &quot;;
    cin &amp;gt;&amp;gt; Height;
    cout &amp;lt;&amp;lt; &quot;Width: &quot;;
    cin &amp;gt;&amp;gt; Width;
}

void Paper::Properties()
{
    cout &amp;lt;&amp;lt; &quot;\n\tHeight    = &quot; &amp;lt;&amp;lt; Height;
    cout &amp;lt;&amp;lt; &quot;\n\tWidth     = &quot; &amp;lt;&amp;lt; Width;
    cout &amp;lt;&amp;lt; &quot;\n\tPerimeter = &quot; &amp;lt;&amp;lt; Perimeter();
    cout &amp;lt;&amp;lt; &quot;\n\tArea      = &quot; &amp;lt;&amp;lt; Area();
    cout &amp;lt;&amp;lt; &quot;\n\n&quot;;
}

double Paper::Perimeter() const
{
 return 2 + (Height * Width);
}

double Paper::Area() const
{
 return Height * Width;
}

void main()
{
    int Samples;
    Paper Label[100];

    cout &amp;lt;&amp;lt; &quot;How many sample labels do you want? &quot;;
    cin &amp;gt;&amp;gt; Samples;

    for(int i = 0; i &amp;lt; Samples; ++i)
        Label[i].GetDimensions();

    cout &amp;lt;&amp;lt; &quot;\n\nHere are the characteristics of your labels\n&quot;;
    for(int j = 0; j &amp;lt; Samples; ++j)
    {
        cout &amp;lt;&amp;lt; &quot;Label No. &quot; &amp;lt;&amp;lt; j;
        Label[j].Properties();
    }
}&lt;/pre&gt;&lt;br /&gt;
Here is an example of running the program:  &lt;br /&gt;
&lt;pre&gt;How many sample labels do you want? 2

Enter the dimensions of the label
Height: 3.25
Width: 3.25

Enter the dimensions of the label
Height: 2.15
Width: 4.55


Here are the characteristics of your labels

Label No. 0
        Height    = 3.25
        Width     = 3.25
        Perimeter = 12.5625
        Area      = 10.5625

Label No. 1

        Height    = 2.15
        Width     = 4.55
        Perimeter = 11.7825
        Area      = 9.7825

&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/2427605801699405185/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/object-declared-as-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/2427605801699405185'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/2427605801699405185'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/object-declared-as-array.html' title='An object declared as an array'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-6676471229405567580</id><published>2012-05-28T18:45:00.002-07:00</published><updated>2012-05-28T18:45:39.775-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>An object as a function argument</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;ParaJust&quot;&gt;This example demonstrates how an object can be made an argument of   a function.&lt;/div&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#include &amp;lt;iostream.h&amp;gt;

struct Paper

{

 double Width;

 double Height;

};



void MagazineCover(Paper ppr)

{

    cout &amp;lt;&amp;lt; &quot;Characteristics of this piece of paper&quot;;

    cout &amp;lt;&amp;lt; &quot;\nWidth     = &quot; &amp;lt;&amp;lt; ppr.Width;

    cout &amp;lt;&amp;lt; &quot;\nHeight    = &quot; &amp;lt;&amp;lt; ppr.Height;

    cout &amp;lt;&amp;lt; &quot;\nPerimeter = &quot; &amp;lt;&amp;lt; 2 + (ppr.Width + ppr.Height);

    cout &amp;lt;&amp;lt; &quot;\nArea      = &quot; &amp;lt;&amp;lt; ppr.Width * ppr.Height;

}



int main(int argc, char* argv[])

{

    double w, h;



    cout &amp;lt;&amp;lt; &quot;Provide the dimensions of the magazine cover\n&quot;;

    cout &amp;lt;&amp;lt; &quot;Width: &quot;;

    cin &amp;gt;&amp;gt; w;

    cout &amp;lt;&amp;lt; &quot;Height: &quot;;

    cin &amp;gt;&amp;gt; h;



    Paper Cover = {w, h};

    MagazineCover(Cover);



    getchar();

    return 0;

}&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/6676471229405567580/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/object-as-function-argument.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/6676471229405567580'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/6676471229405567580'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/object-as-function-argument.html' title='An object as a function argument'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-1393287378469811011</id><published>2012-05-28T18:43:00.000-07:00</published><updated>2012-05-28T18:43:22.901-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>Initializing the Members of a Class Using a Constructor</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;ParaJust&quot;&gt;This  example uses a class that contains a constructor      used to  initialize the object. The class is called ShoeBox. When supplied with a  length, a height,      and a width, the object should calculate and  display the total area of all      sides and the volume.&lt;/div&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;width: 700px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;    &lt;td width=&quot;100%&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;Header File: shoebox.h&lt;/span&gt;    &lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;      &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#ifndef SHOEBOX_H&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#define SHOEBOX_H&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;class ShoeBox{&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;public:&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;ShoeBox(double l, double h, double w);&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;double getLength() const;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double getHeight() const;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double getWidth() const;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;void Properties();&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double Area() const;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double Volume() const;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;private:&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double Length;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double Height;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double Width;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;};&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#endif&lt;/pre&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;width: 700px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;    &lt;td width=&quot;100%&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;Source File: shoebox.h&lt;/span&gt;    &lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;      &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#include &quot;box.h&quot;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;ShoeBox::ShoeBox(double l, double h, double w)&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{ Length = l;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;Height = h;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Width  = w;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double ShoeBox::getLength() const&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{ return Length;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double ShoeBox::getHeight() const&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{ return Height;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}double ShoeBox::getWidth() const{&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;return Width;}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double ShoeBox::Area() const&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;return 2 * ((Length * Height) + (Height + Width) + (Length * Width));&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}double ShoeBox::Volume() const&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{ return Length * Height * Width;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}void ShoeBox::Properties(){&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;Properties of the shoe box&quot;;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\nLength = &quot; &amp;lt;&amp;lt; getLength();&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\nHeight = &quot; &amp;lt;&amp;lt; getHeight();&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\nWidth  = &quot; &amp;lt;&amp;lt; getWidth();&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\nArea   = &quot; &amp;lt;&amp;lt; Area();&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\nVolume = &quot; &amp;lt;&amp;lt; Volume() &amp;lt;&amp;lt; &quot;\n\n&quot;;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}&lt;/pre&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;width: 660px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;    &lt;td width=&quot;100%&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;Header File: cube.h&lt;/span&gt;    &lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;      &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#include &quot;box.h&quot;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;void main()&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{ ShoeBox Size6(8.65, 4.25, 4.15);&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;Size6.Properties();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}&lt;/pre&gt;Here is a result of running the program&lt;pre&gt;Properties of the shoe boxLength = 8.65&lt;/pre&gt;&lt;pre&gt;Height = 4.25&lt;/pre&gt;&lt;pre&gt;Width  = 4.15&lt;/pre&gt;&lt;pre&gt;Area   = 162.12&lt;/pre&gt;&lt;pre&gt;Volume = 152.564&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/1393287378469811011/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/initializing-members-of-class-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/1393287378469811011'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/1393287378469811011'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/initializing-members-of-class-using.html' title='Initializing the Members of a Class Using a Constructor'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-7217190790797595084</id><published>2012-05-28T18:37:00.000-07:00</published><updated>2012-05-28T18:37:15.489-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>A Simple Class</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;width: 740px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td valign=&quot;top&quot; width=&quot;70&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;Exercise&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;    &lt;td bgcolor=&quot;#FF9900&quot; valign=&quot;top&quot; width=&quot;1&quot;&gt;&lt;br /&gt;
&lt;/td&gt;    &lt;td valign=&quot;top&quot; width=&quot;&quot;&gt;&lt;br /&gt;
&lt;/td&gt;    &lt;td&gt;Write  a simple class called Cube. The object should calculate the total       area and&lt;br /&gt;
&amp;nbsp; the volume based on the side measurement. If the program  supplies      a side &lt;br /&gt;
&amp;nbsp;equal or lower than 0, reset the side to 1. Create  an empty      constructor and an &lt;br /&gt;
&amp;nbsp;empty destructor.      Implement the object in different files.&lt;/td&gt;  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;width: 700px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;    &lt;td width=&quot;100%&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;Header File: cube.h&lt;/span&gt;    &lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;      &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#ifndef CUBE_H&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#define CUBE_H&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;class Cube&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{public:&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Cube();&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;~Cube();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;void setSide(double s);&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;double getSide();&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double Area();&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double Volume();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;void Properties();private:&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;double Side;};&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#endif&lt;/pre&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;width: 700px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;    &lt;td width=&quot;100%&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;Source File cube.cpp&lt;/span&gt;    &lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;      &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#include &quot;cube.h&quot;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Cube::Cube(){}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Cube::~Cube(){}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;void Cube::setSide(double s)&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{ Side = s &amp;lt;= 0 ? 1 : s;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}double Cube::getSide()&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{ return Side;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}double Cube::Area()&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{ return 6 * Side * Side;}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;double Cube::Volume()&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{ return Side * Side * Side;}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;void Cube::Properties(){&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;Characteristics of this cube&quot;;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\nSide   = &quot; &amp;lt;&amp;lt; getSide();&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\nArea   = &quot; &amp;lt;&amp;lt; Area();&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\nVolume = &quot; &amp;lt;&amp;lt; Volume() &amp;lt;&amp;lt; &quot;\n\n&quot;;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}&lt;/pre&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;width: 700px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;    &lt;td width=&quot;100%&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;Main File: Exo.cpp&lt;/span&gt;    &lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;      &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#include &quot;cube.h&quot;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;void main()&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Cube cube;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cube.setSide(-12.55);&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cube.Properties();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;Cube de;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;de.setSide(28.15);&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;de.Properties();&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;}&lt;/pre&gt;Here is an example of the result:&lt;pre class=&quot;CodeFormat&quot;&gt;Characteristics of this cubeSide   = 1&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Area   = 6&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Volume = 1&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Characteristics of this cubeSide   = 28.15&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Area   = 4754.53&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Volume = 22306.7&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/7217190790797595084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/simple-class.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/7217190790797595084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/7217190790797595084'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/simple-class.html' title='A Simple Class'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-8803046060836432139</id><published>2012-05-28T18:30:00.002-07:00</published><updated>2012-05-28T18:30:44.424-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>Greatest Common Divisor 2</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;pre&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

int GCD(int a, int b)
{
    while( 1 )
    {
        a = a % b;
  if( a == 0 )
   return b;
  b = b % a;

        if( b == 0 )
   return a;
    }
}

int main()
{
 int x, y;

 cout &amp;lt;&amp;lt; &quot;This program allows calculating the GCD\n&quot;;
 cout &amp;lt;&amp;lt; &quot;Value 1: &quot;;
 cin &amp;gt;&amp;gt; x;
 cout &amp;lt;&amp;lt; &quot;Value 2: &quot;;
 cin &amp;gt;&amp;gt; y;

 cout &amp;lt;&amp;lt; &quot;\nThe Greatest Common Divisor of &quot;
      &amp;lt;&amp;lt; x &amp;lt;&amp;lt; &quot; and &quot; &amp;lt;&amp;lt; y &amp;lt;&amp;lt; &quot; is &quot; &amp;lt;&amp;lt; GCD(x, y) &amp;lt;&amp;lt; endl;  

 return 0;
}&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/8803046060836432139/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/greatest-common-divisor-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/8803046060836432139'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/8803046060836432139'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/greatest-common-divisor-2.html' title='Greatest Common Divisor 2'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-1601844708062492451</id><published>2012-05-28T18:28:00.002-07:00</published><updated>2012-05-28T18:28:53.079-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>Greatest Common Divisor</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

int GCD(int a, int b)
{
    int Remainder;

    while( b != 0 )
    {
        Remainder = a % b;
        a = b;
        b = Remainder;
    }

    return a;
}

int main()
{
 int x, y;

 cout &amp;lt;&amp;lt; &quot;This program allows calculating the GCD\n&quot;;
 cout &amp;lt;&amp;lt; &quot;Value 1: &quot;;
 cin &amp;gt;&amp;gt; x;
 cout &amp;lt;&amp;lt; &quot;Value 2: &quot;;
 cin &amp;gt;&amp;gt; y;

 cout &amp;lt;&amp;lt; &quot;\nThe Greatest Common Divisor of &quot;
      &amp;lt;&amp;lt; x &amp;lt;&amp;lt; &quot; and &quot; &amp;lt;&amp;lt; y &amp;lt;&amp;lt; &quot; is &quot; &amp;lt;&amp;lt; GCD(x, y) &amp;lt;&amp;lt; endl;  

 return 0;
}&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/1601844708062492451/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/greatest-common-divisor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/1601844708062492451'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/1601844708062492451'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/greatest-common-divisor.html' title='Greatest Common Divisor'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-5580204082724470516</id><published>2012-05-28T18:20:00.002-07:00</published><updated>2012-05-28T18:20:44.195-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>Passing an Object as Argument</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;ParaJust&quot;&gt;This example demonstrates how an object can be made an argument of   a function.&lt;/div&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#include &amp;lt;iostream.h&amp;gt;

struct Paper

{

 double Width;

 double Height;

};



void MagazineCover(Paper ppr)

{

    cout &amp;lt;&amp;lt; &quot;Characteristics of this piece of paper&quot;;

    cout &amp;lt;&amp;lt; &quot;\nWidth     = &quot; &amp;lt;&amp;lt; ppr.Width;

    cout &amp;lt;&amp;lt; &quot;\nHeight    = &quot; &amp;lt;&amp;lt; ppr.Height;

    cout &amp;lt;&amp;lt; &quot;\nPerimeter = &quot; &amp;lt;&amp;lt; 2 + (ppr.Width + ppr.Height);

    cout &amp;lt;&amp;lt; &quot;\nArea      = &quot; &amp;lt;&amp;lt; ppr.Width * ppr.Height;

}



int main(int argc, char* argv[])

{

    double w, h;



    cout &amp;lt;&amp;lt; &quot;Provide the dimensions of the magazine cover\n&quot;;

    cout &amp;lt;&amp;lt; &quot;Width: &quot;;

    cin &amp;gt;&amp;gt; w;

    cout &amp;lt;&amp;lt; &quot;Height: &quot;;

    cin &amp;gt;&amp;gt; h;



    Paper Cover = {w, h};

    MagazineCover(Cover);



    getchar();

    return 0;

}&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/5580204082724470516/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/passing-object-as-argument.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/5580204082724470516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/5580204082724470516'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/passing-object-as-argument.html' title='Passing an Object as Argument'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-4392488406111545406</id><published>2012-05-28T10:17:00.000-07:00</published><updated>2012-05-28T10:17:26.248-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>Passing Arguments</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;#include &amp;lt;iostream.h&amp;gt;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;void main(){&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;int Boys = 3, Girls = 5;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;void PassByValue(int males, int females);&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;void Reference(int &amp;amp;m, int &amp;amp;f);&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;void Pointers(int *u, int *v);&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;At startup, within main()&quot;; 
cout &amp;lt;&amp;lt; &quot;\n\tBoys  = &quot; &amp;lt;&amp;lt; Boys;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\n\tGirls = &quot; &amp;lt;&amp;lt; Girls;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\nPassing arguments by value = Copy&quot;;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;PassByValue(Boys, Girls);&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\nAfter calling PassByValue(), within main()&quot;;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\n\tBoys  = &quot; &amp;lt;&amp;lt; Boys;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\n\tGirls = &quot; &amp;lt;&amp;lt; Girls;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\nPassing arguments by reference&quot;;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;Reference(Boys, Girls);&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\nAfter calling Reference(), within main()&quot;;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\n\tBoys  = &quot; &amp;lt;&amp;lt; Boys;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\n\tGirls = &quot; &amp;lt;&amp;lt; Girls;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\nPassing arguments pointers&quot;;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;Pointers(&amp;amp;Boys, &amp;amp;Girls);&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\nAfter calling Pointers(), within main()&quot;;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\n\tBoys  = &quot; &amp;lt;&amp;lt; Boys;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\n\tGirls = &quot; &amp;lt;&amp;lt; Girls;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\n&quot;;}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;void PassByValue(int b, int g)&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;{ b += 3, g += 4;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\nWithin PassByValue(), now&quot;;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\n\tBoys  = &quot; &amp;lt;&amp;lt; b;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\n\tGirls = &quot; &amp;lt;&amp;lt; g;}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;void Reference(int &amp;amp;b, int &amp;amp;g)
{ b = b + 8, g = g + 5;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\nWithin Reference(), now&quot;;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\n\tBoys  = &quot; &amp;lt;&amp;lt; b;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\n\tGirls = &quot; &amp;lt;&amp;lt; g;}&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;void Pointers(int *b, int *g){&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;*b = 44, *g = 52;&amp;nbsp;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;cout &amp;lt;&amp;lt; &quot;\nWithin Pointers(), now&quot;;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\n\tBoys  = &quot; &amp;lt;&amp;lt; *b;&lt;/pre&gt;&lt;pre class=&quot;CodeFormat&quot;&gt;&amp;nbsp;cout &amp;lt;&amp;lt; &quot;\n\tGirls = &quot; &amp;lt;&amp;lt; *g;}&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/4392488406111545406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/passing-arguments.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/4392488406111545406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/4392488406111545406'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/passing-arguments.html' title='Passing Arguments'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-3855625311748561123</id><published>2012-05-28T10:03:00.002-07:00</published><updated>2012-05-28T10:03:36.170-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>Passing Arguments by Value</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;pre&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;string&amp;gt;
using namespace std;

string GetName()
{
    string FirstName, LastName, FN;   

    cout &amp;lt;&amp;lt; &quot;Employee&#39;s First Name: &quot;;
    cin &amp;gt;&amp;gt; FirstName;
    cout &amp;lt;&amp;lt; &quot;Employee&#39;s Last Name: &quot;;
    cin &amp;gt;&amp;gt; LastName;  

    FN = FirstName + &quot; &quot; + LastName;

    return FN;
}

int main()
{
    string FullName;
    double Hours;

    double GetHours(string FullName);

    FullName = GetName();

    Hours = GetHours(FullName);

    cout &amp;lt;&amp;lt; &quot;\nEmployee&#39;s Name: &quot; &amp;lt;&amp;lt; FullName;
    cout &amp;lt;&amp;lt; &quot;\nWeekly Hours: &quot; &amp;lt;&amp;lt; Hours &amp;lt;&amp;lt; &quot; hours\n\n&quot;;

    return 0;
}

double GetHours(string FullName)
{
    double Mon, Tue, Wed, Thu, Fri, TotalHours;   

    cout &amp;lt;&amp;lt; endl &amp;lt;&amp;lt; FullName &amp;lt;&amp;lt; &quot;&#39;s Weekly Hours\n&quot;;
    cout &amp;lt;&amp;lt; &quot;Monday: &quot;;
    cin &amp;gt;&amp;gt; Mon;
    cout &amp;lt;&amp;lt; &quot;Tuesday: &quot;;
    cin &amp;gt;&amp;gt; Tue;
    cout &amp;lt;&amp;lt; &quot;Wednesday: &quot;;
    cin &amp;gt;&amp;gt; Wed;
    cout &amp;lt;&amp;lt; &quot;Thursday: &quot;;
    cin &amp;gt;&amp;gt; Thu;
    cout &amp;lt;&amp;lt; &quot;Friday: &quot;;
    cin &amp;gt;&amp;gt; Fri;  

    TotalHours = Mon + Tue + Wed + Thu + Fri;

    return TotalHours;
}&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/3855625311748561123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/passing-arguments-by-value.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/3855625311748561123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/3855625311748561123'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/passing-arguments-by-value.html' title='Passing Arguments by Value'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-2957706796762509783</id><published>2012-05-28T10:00:00.002-07:00</published><updated>2012-05-28T10:02:29.041-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>C++ Examples: If-Else</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;width: 740px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td valign=&quot;top&quot; width=&quot;59&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;Exercise&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;      &lt;td bgcolor=&quot;#FF9900&quot; valign=&quot;top&quot; width=&quot;1&quot;&gt;&lt;br /&gt;
&lt;/td&gt;      &lt;td valign=&quot;top&quot; width=&quot;20&quot;&gt;&lt;br /&gt;
&lt;/td&gt;      &lt;td&gt;The LeVan Car Rental company charges $0.25/mile if the total mileage does  not exceed&lt;br /&gt;
&amp;nbsp;100.If the total mileage is over 100, the company charges $0.25/mile  for the first 100&lt;br /&gt;
&amp;nbsp;miles, thenit charges $0.15/mile for any additional mileage  over 100.        Write a program&lt;br /&gt;
so that if the clerk enters the number of miles, the        program would display the total price owed.&lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;width: 700px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;       &lt;/tr&gt;
&lt;tr&gt;      &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;pre&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

void main()
{
    unsigned int Miles;
    const double LessThan100 = 0.25;
    const double MoreThan100 = 0.15;
    double PriceLessThan100, PriceMoreThan100, TotalPrice;

    cout &amp;lt;&amp;lt; &quot;Enter the number of miles: &quot;;
    cin &amp;gt;&amp;gt; Miles;

    if(Miles &amp;lt;= 100)
    {
        PriceLessThan100 = Miles * LessThan100;
        PriceMoreThan100 = 0;
    }
    else
    {
        PriceLessThan100 = 100 * LessThan100;
        PriceMoreThan100 = (Miles - 100) * MoreThan100;
    }

    TotalPrice = PriceLessThan100 + PriceMoreThan100;

    cout &amp;lt;&amp;lt; &quot;\nTotal Price = $&quot; &amp;lt;&amp;lt; TotalPrice &amp;lt;&amp;lt; &quot;\n\n&quot;;
}&lt;/pre&gt;Here is an example of running the program:&amp;nbsp;  &lt;br /&gt;
&lt;table bgcolor=&quot;#F2F2F2&quot; border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;width: 500px;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;      &lt;td width=&quot;100%&quot;&gt;Enter the number of miles: 75&lt;br /&gt;
&lt;br /&gt;
Total Price = $18.75&lt;br /&gt;
&lt;br /&gt;
Press any key to continue&lt;/td&gt;    &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;ins style=&quot;border: none; display: inline-table; height: 90px; margin: 0; padding: 0; position: relative; visibility: visible; width: 728px;&quot;&gt;&lt;/ins&gt;&lt;br /&gt;
&lt;ins id=&quot;aswift_1_anchor&quot; style=&quot;border: none; display: block; height: 90px; margin: 0; padding: 0; position: relative; visibility: visible; width: 728px;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/2957706796762509783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-examples-if-else.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/2957706796762509783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/2957706796762509783'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-examples-if-else.html' title='C++ Examples: If-Else'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-6108224055262617029</id><published>2012-05-28T09:57:00.003-07:00</published><updated>2012-05-28T09:58:16.180-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c++programs"/><title type='text'>A Simple C++ Program</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;ParaJust&quot;&gt;This is the simples C++ program. It displays a sentence on the console        or the terminal&lt;/div&gt;&lt;span style=&quot;color: red;&quot;&gt;Version 1&lt;/span&gt;  &lt;br /&gt;
&lt;pre&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

int main()
{
 std::cout &amp;lt;&amp;lt; &quot;Welcome to the wonderful world of C++!!!\n&quot;;

 return 0;

}&lt;/pre&gt;Version 2&lt;br /&gt;
&lt;pre&gt;#include &amp;lt;iostream&amp;gt;
using namespace std;

int main()
{
 cout &amp;lt;&amp;lt; &quot;Welcome to the wonderful world of C++!!!\n&quot;;

 return 0;
}&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/6108224055262617029/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/simple-c-program.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/6108224055262617029'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/6108224055262617029'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/simple-c-program.html' title='A Simple C++ Program'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-9011420076457220052</id><published>2012-05-28T00:35:00.002-07:00</published><updated>2012-05-28T00:35:57.373-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cprogramming"/><title type='text'>C program to shutdown or turn off computer</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;content clearfix&quot;&gt;     C Program to shutdown your computer: This program turn off i.e  shutdown your computer system. Firstly it will asks you to shutdown your  computer if you press &#39;y&#39; the your computer will shutdown in 30  seconds, system function of &quot;stdlib.h&quot; is used to run an executable file  shutdown.exe which is present in C:\WINDOWS\system32 in Windows XP. You  can use various options while executing shutdown.exe for example -s  option shutdown the computer after 30 seconds, if you wish to shutdown  immediately then you can write &quot;shutdown -s -t 0&quot; as an argument to  system function. If you wish to restart your computer then you can write  &quot;shutdown -r&quot;.&lt;br /&gt;
&lt;div style=&quot;color: red;&quot;&gt;If you are using Turbo C Compiler then execute  your file from folder. Press F9 to build your executable file from  source program. When you run from within the compiler by pressing  Ctrl+F9 it may not work.&lt;/div&gt;&lt;h2&gt;C programming code for Windows XP&lt;/h2&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;c geshifilter-c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/span&gt;
&amp;nbsp;
main&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt; ch&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Do you want to shutdown your computer now (y/n)&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%c&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&amp;amp;&lt;/span&gt;ch&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;ch &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&#39;y&#39;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;||&lt;/span&gt; ch &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&#39;Y&#39;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;kw3&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;C:&lt;span class=&quot;es1&quot;&gt;\\&lt;/span&gt;WINDOWS&lt;span class=&quot;es1&quot;&gt;\\&lt;/span&gt;System32&lt;span class=&quot;es1&quot;&gt;\\&lt;/span&gt;shutdown -s&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2&gt;C programming code for Windows 7&lt;/h2&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;c geshifilter-c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/span&gt;
&amp;nbsp;
main&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt; ch&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Do you want to shutdown your computer now (y/n)&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%c&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&amp;amp;&lt;/span&gt;ch&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;ch &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&#39;y&#39;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;||&lt;/span&gt; ch &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&#39;Y&#39;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;kw3&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;C:&lt;span class=&quot;es1&quot;&gt;\\&lt;/span&gt;WINDOWS&lt;span class=&quot;es1&quot;&gt;\\&lt;/span&gt;System32&lt;span class=&quot;es1&quot;&gt;\\&lt;/span&gt;shutdown /s&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;To shutdown immediately use &quot;C:\\WINDOWS\\System32\\ shutdown /s /t 0&quot;. To restart use /r instead of /s.&lt;br /&gt;
&lt;h2&gt;C programming code for Ubuntu Linux&lt;/h2&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;c geshifilter-c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; main&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kw3&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;shutdown -P now&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt; &lt;/pre&gt;&lt;/div&gt;You need to be logged in as &lt;strong&gt;root&lt;/strong&gt; user for above program to execute otherwise you will get the message &lt;em&gt;shutdown: Need to be root&lt;/em&gt;, &lt;strong&gt;now&lt;/strong&gt;  specifies that you want to shutdown immediately. &#39;-P&#39; option specifes  you want to power off your machine. You can specify minutes as:&lt;br /&gt;
shutdown -P &quot;number of minutes&quot;&lt;br /&gt;
For more help or options type at terminal: man shutdown. &lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/9011420076457220052/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-program-to-shutdown-or-turn-off.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/9011420076457220052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/9011420076457220052'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-program-to-shutdown-or-turn-off.html' title='C program to shutdown or turn off computer'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-1519803733235454037</id><published>2012-05-28T00:34:00.000-07:00</published><updated>2012-05-28T00:34:02.993-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cprogramming"/><title type='text'>c program to get ip address</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;content clearfix&quot;&gt;     This c program prints ip (internet protocol) address of your  computer, system function is used to execute the command ipconfig which  prints ip address, subnet mask and default gateway. The code given below  works for Windows xp and Windows 7. If you are using turbo c compiler  then execute program from folder, it may not work when you are working  in compiler and press Ctrl+F9 to run your program.&lt;br /&gt;
&lt;h2&gt;C programming code&lt;/h2&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;c geshifilter-c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;
&amp;nbsp;
main&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;C:&lt;span class=&quot;es1&quot;&gt;\\&lt;/span&gt;Windows&lt;span class=&quot;es1&quot;&gt;\\&lt;/span&gt;System32&lt;span class=&quot;es1&quot;&gt;\\&lt;/span&gt;ipconfig&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;system&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;pause&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;a href=&quot;http://www.programmingsimplified.com/toolsArea/executable/get%20ip%20address%20www.programmingsimplified.com&quot;&gt;IP address&lt;/a&gt; program executable.&lt;br /&gt;
Output of program: ( In Windows XP )&lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;ip address&quot; src=&quot;http://www.programmingsimplified.com/toolsArea/images/get%20ip%20address.png&quot; /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;block block-block block-odd region-odd clearfix&quot; id=&quot;block-block-35&quot;&gt;     &lt;div class=&quot;content&quot;&gt;     &lt;ins style=&quot;border: none; display: inline-table; height: 280px; margin: 0; padding: 0; position: relative; visibility: visible; width: 336px;&quot;&gt;&lt;ins id=&quot;aswift_2_anchor&quot; style=&quot;border: none; display: block; height: 280px; margin: 0; padding: 0; position: relative; visibility: visible; width: 336px;&quot;&gt;&lt;br /&gt;
&lt;/ins&gt;&lt;/ins&gt;  &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/1519803733235454037/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-program-to-get-ip-address.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/1519803733235454037'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/1519803733235454037'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-program-to-get-ip-address.html' title='c program to get ip address'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-8136376059528373692</id><published>2012-05-28T00:26:00.002-07:00</published><updated>2012-05-28T00:26:23.950-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cprogramming"/><title type='text'>c program to print date</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;content clearfix&quot;&gt;     This c program prints current system date. To print date we will use getdate function.&lt;br /&gt;
&lt;h2&gt;C programming code&lt;/h2&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;c geshifilter-c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include&amp;lt;dos.h&amp;gt;&lt;/span&gt;
&amp;nbsp;
main&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kw4&quot;&gt;struct&lt;/span&gt; date d&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   getdate&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;d&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Current system date is %d/%d/%d&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;d.&lt;span class=&quot;me1&quot;&gt;da_day&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;d.&lt;span class=&quot;me1&quot;&gt;da_mon&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;d.&lt;span class=&quot;me1&quot;&gt;da_year&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;getch&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3&gt;Output of program&lt;/h3&gt;&lt;img alt=&quot;date&quot; src=&quot;http://www.programmingsimplified.com/sites/default/files/date.png&quot; /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/8136376059528373692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-program-to-print-date.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/8136376059528373692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/8136376059528373692'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-program-to-print-date.html' title='c program to print date'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-4070811006739606991</id><published>2012-05-28T00:16:00.002-07:00</published><updated>2012-05-28T00:16:43.686-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cprogramming"/><title type='text'>c program to add two complex numbers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;content clearfix&quot;&gt;     c program to add two complex numbers :- This program calculate  the sum of two complex numbers which will be entered by the user and  then prints it. User will have to enter the real and imaginary parts of  two complex numbers. In our program we will add real parts and imaginary  parts of complex numbers and prints the complex number, i is the symbol  used for iota. For example if user entered two complex numbers as (1 +  2i) and (4 + 6 i) then output of program will be (5+8i).  A structure is  used to store complex number.&lt;br /&gt;
&lt;h2&gt;C programming code&lt;/h2&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;c geshifilter-c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;struct&lt;/span&gt; complex
&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; real&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; img&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
main&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kw4&quot;&gt;struct&lt;/span&gt; complex a&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; b&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; c&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Enter a and b where a + ib is the first complex number.&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;a = &quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;a.&lt;span class=&quot;me1&quot;&gt;real&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;b = &quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;a.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Enter c and d where c + id is the second complex number.&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;c = &quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;b.&lt;span class=&quot;me1&quot;&gt;real&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;d = &quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;b.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   c.&lt;span class=&quot;me1&quot;&gt;real&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; a.&lt;span class=&quot;me1&quot;&gt;real&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt; b.&lt;span class=&quot;me1&quot;&gt;real&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   c.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; a.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt; b.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt; c.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Sum of two complex numbers = %d + %di&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;c.&lt;span class=&quot;me1&quot;&gt;real&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;c.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;
      &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Sum of two complex numbers = %d %di&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;c.&lt;span class=&quot;me1&quot;&gt;real&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;c.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;Download &lt;a href=&quot;http://www.programmingsimplified.com/toolsArea/executable/add%20two%20complex%20numbers.EXE&quot; title=&quot;Executable file of c program to add two complex numbers&quot;&gt;add complex numbers&lt;/a&gt; program executable.&lt;br /&gt;
Output of c program to add two complex numbers is shown in image below :-&lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;output of c program to add two complex numbers&quot; src=&quot;http://www.programmingsimplified.com/toolsArea/images/add%20two%20complex%20numbers.png&quot; /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/4070811006739606991/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-program-to-add-two-complex-numbers_28.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/4070811006739606991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/4070811006739606991'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-program-to-add-two-complex-numbers_28.html' title='c program to add two complex numbers'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-696617260643351778</id><published>2012-05-28T00:15:00.000-07:00</published><updated>2012-05-28T00:15:00.948-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cprogramming"/><title type='text'>c program to add two complex numbers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;content clearfix&quot;&gt;     c program to add two complex numbers :- This program calculate  the sum of two complex numbers which will be entered by the user and  then prints it. User will have to enter the real and imaginary parts of  two complex numbers. In our program we will add real parts and imaginary  parts of complex numbers and prints the complex number, i is the symbol  used for iota. For example if user entered two complex numbers as (1 +  2i) and (4 + 6 i) then output of program will be (5+8i).  A structure is  used to store complex number.&lt;br /&gt;
&lt;h2&gt;C programming code&lt;/h2&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;c geshifilter-c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;struct&lt;/span&gt; complex
&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; real&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; img&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
main&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kw4&quot;&gt;struct&lt;/span&gt; complex a&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; b&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; c&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Enter a and b where a + ib is the first complex number.&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;a = &quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;a.&lt;span class=&quot;me1&quot;&gt;real&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;b = &quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;a.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Enter c and d where c + id is the second complex number.&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;c = &quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;b.&lt;span class=&quot;me1&quot;&gt;real&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;d = &quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;b.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   c.&lt;span class=&quot;me1&quot;&gt;real&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; a.&lt;span class=&quot;me1&quot;&gt;real&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt; b.&lt;span class=&quot;me1&quot;&gt;real&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   c.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; a.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt; b.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt; c.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Sum of two complex numbers = %d + %di&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;c.&lt;span class=&quot;me1&quot;&gt;real&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;c.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;
      &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Sum of two complex numbers = %d %di&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;c.&lt;span class=&quot;me1&quot;&gt;real&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;c.&lt;span class=&quot;me1&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;Download &lt;a href=&quot;http://www.programmingsimplified.com/toolsArea/executable/add%20two%20complex%20numbers.EXE&quot; title=&quot;Executable file of c program to add two complex numbers&quot;&gt;add complex numbers&lt;/a&gt; program executable.&lt;br /&gt;
Output of c program to add two complex numbers is shown in image below :-&lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;output of c program to add two complex numbers&quot; src=&quot;http://www.programmingsimplified.com/toolsArea/images/add%20two%20complex%20numbers.png&quot; /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/696617260643351778/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-program-to-add-two-complex-numbers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/696617260643351778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/696617260643351778'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-program-to-add-two-complex-numbers.html' title='c program to add two complex numbers'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8999922090094507351.post-2418851034751171210</id><published>2012-05-28T00:14:00.000-07:00</published><updated>2012-05-28T00:14:03.552-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cprogramming"/><title type='text'>c program to generate random numbers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;h1 class=&quot;title&quot;&gt;c program to generate random numbers&lt;/h1&gt;&lt;div class=&quot;meta&quot;&gt;                       &lt;/div&gt;This c program generates random numbers using random function,  randomize function is used to initialize random number generator. If you  don&#39;t use randomize function then you will get same random numbers each  time you run the program.&lt;br /&gt;
&lt;h2&gt;C programming code using rand&lt;/h2&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;c geshifilter-c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; main&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; c&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; n&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Ten random numbers in [1,100]&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;c &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; c &lt;span class=&quot;sy0&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; c&lt;span class=&quot;sy0&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
    n &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw3&quot;&gt;rand&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;nu19&quot;&gt;100&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; n&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2&gt;C programming code using random function(Turbo C compiler only)&lt;/h2&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;pre class=&quot;c geshifilter-c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include&amp;lt;conio.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;
&amp;nbsp;
main&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; n&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; max&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; num&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; c&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Enter the number of random numbers you want &quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&amp;amp;&lt;/span&gt;n&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Enter the maximum value of random number &quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw3&quot;&gt;scanf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&amp;amp;&lt;/span&gt;max&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d random numbers from 0 to %d are :-&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;n&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;max&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   randomize&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt; c &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; c &lt;span class=&quot;sy0&quot;&gt;&amp;lt;=&lt;/span&gt; n &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; c&lt;span class=&quot;sy0&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;
   &lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
      num &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; random&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;max&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
      &lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;%d&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;num&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;kw3&quot;&gt;getch&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Click Here to Subscribe !!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forgetprograms.blogspot.com/feeds/2418851034751171210/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-program-to-generate-random-numbers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/2418851034751171210'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8999922090094507351/posts/default/2418851034751171210'/><link rel='alternate' type='text/html' href='http://forgetprograms.blogspot.com/2012/05/c-program-to-generate-random-numbers.html' title='c program to generate random numbers'/><author><name>PrasannaKumar</name><uri>http://www.blogger.com/profile/13922616802554131728</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFmwgItYXE5cJRKyD_hBLaBW8VapXidQt8twe_ymrvzVB7apJFW7h_bAOcsQgtUUMRQAGv-nAvpEdjZ820_iD8VMtqLtsf0t55NZRgYBBIEmQbzkeAysTcMT-7JeCMSA/s113/prasurmimarr.JPG'/></author><thr:total>0</thr:total></entry></feed>