Advertisement
Java_Volume1 Complete Applications #100026

C++ Intro...

This tutorial has been made to give an introduction to new c++ programmers. Unfortunately their are many great minds out there but they don't have access to free and quality c++ tutorials. So this is the first lesson.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
<h1>C++ Intro&#8230;<span style="mso-tab-count:1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="mso-tab-count:2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="mso-tab-count:1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:16.0pt;
mso-bidi-font-size:12.0pt;font-weight:normal">By: Amin Patel</span></h1>
<p class="MsoNormal">Before you write your first program. Start with a prayer to
God, that you &#8220;Succeed in learning C++&#8221;.</p>
<p class="MsoNormal">&nbsp;<o:p>
</o:p>
</p>
<p class="MsoNormal">Now that all your hopes are high let us start. Please enter
the following code exactly as shown, without any questions. (This is to inform
you that the explanation will follow after the code.)</p>
<p class="MsoNormal">&nbsp;<o:p>
</o:p>
</p>
<table border="1" cellspacing="0" cellpadding="0" style="margin-left:.2in;border-collapse:
 collapse;border:none;mso-border-alt:solid windowtext .5pt;mso-padding-alt:
 0in 5.4pt 0in 5.4pt">
 <tr style="height:73.75pt">
  <td width="419" valign="top" style="width:314.55pt;border:solid windowtext .5pt;
 padding:0in 5.4pt 0in 5.4pt;height:73.75pt">
   <ol style="margin-top:0in" start="1" type="1">
    <li class="MsoNormal" style="mso-list:l0 level1 lfo1;tab-stops:list .5in"><font color="#0000FF">#include</font>
     &lt;iostream.h&gt;</li>
    <li class="MsoNormal" style="mso-list:l0 level1 lfo1;tab-stops:list .5in"><span style="mso-spacerun: yes"><font color="#0000FF">&nbsp;</font></span><font color="#0000FF">int</font>
     main()</li>
    <li class="MsoNormal" style="mso-list:l0 level1 lfo1;tab-stops:list .5in">{</li>
    <li class="MsoNormal" style="mso-list:l0 level1 lfo1;tab-stops:list .5in">cout&lt;&lt;
     &#8220; What you do is what you get&#8221;;</li>
    <li class="MsoNormal" style="mso-list:l0 level1 lfo1;tab-stops:list .5in">}</li>
   </ol>
   <p class="MsoNormal">&nbsp;<o:p>
   </o:p>
   </p>
  </td>
 </tr>
</table>
<p class="MsoNormal">&nbsp;<o:p>
</o:p>
</p>
<p class="MsoNormal">Although this may sound strange, once you <b>compile</b>
this program you are a programmer.</p>
<p class="MsoNormal">&lt;<b>Warning</b>: The numbered indentation is not to be
included with the code while typing. It is only for your convenience&gt;</p>
<p class="MsoNormal">&nbsp;<o:p>
</o:p>
</p>
<p class="MsoNormal">Now let us read the first line. You read it as
&#8220;Hash/Pound include eye-oh-stream-dot-h&#8221;</p>
<p class="MsoNormal">&nbsp;<o:p>
</o:p>
</p>
<table border="1" cellspacing="0" cellpadding="0" width="588" style="width:441.0pt;
 margin-left:5.4pt;border-collapse:collapse;border:none;mso-border-alt:solid windowtext .5pt;
 mso-padding-alt:0in 5.4pt 0in 5.4pt">
 <tr style="height:27.4pt">
  <td width="588" valign="top" style="width:441.0pt;border:solid windowtext .5pt;
 padding:0in 5.4pt 0in 5.4pt;height:27.4pt">
   <p class="MsoNormal"><b>Iostream</b>: Input Output stream. Don&#8217;t learn
   the definitions they automatically come to you.</p>
   <p class="MsoNormal">&nbsp;<o:p>
   </o:p>
   </p>
  </td>
 </tr>
</table>
<p class="MsoNormal"><span style="mso-spacerun: yes">&nbsp;</span></p>
<p class="MsoNormal">You don&#8217;t pronounce the brackets while reading it loud,
but is it a part of the code.</p>
<table border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;
 border:none;mso-border-alt:solid windowtext .5pt;mso-padding-alt:0in 5.4pt 0in 5.4pt">
 <tr>
  <td width="590" valign="top" style="width:6.15in;border:solid windowtext .5pt;
 padding:0in 5.4pt 0in 5.4pt">
   <p class="MsoNormal"><b>.h</b>: Dot h files are known as header files. We
   place them in the beginning of the source code; it is like adding a DVD-Player
   to your deck. You don&#8217;t create <b>.h</b> files for now, nor would you
   add a DVD-Player to your deck each time you want to use it.</p>
  </td>
 </tr>
 <tr>
  <td width="590" valign="top" style="width:6.15in;border:solid windowtext .5pt;
 border-top:none;mso-border-top-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt">
   <p class="MsoNormal"><b>Iostream.h</b>: Ok now you know what <i>iostream</i>
   and dot h stand for. If the terms <i>input</i> &amp; <i>output</i>
   haven&#8217;t shed any light yet, keep reading. <i>Iostream</i> lets your
   program accept info/data/content or publish the same to the screen.</p>
  </td>
 </tr>
</table>
<p class="MsoNormal">&nbsp;<o:p>
</o:p>
</p>
<p class="MsoNormal">Wait we are still on the first line. Read the first line of
source <b>code </b>again!</p>
<p class="MsoNormal">&nbsp;<o:p>
</o:p>
</p>
<p class="MsoNormal">&#8220;Hash/Pound include eye-oh-stream-dot-h&#8221;</p>
<p class="MsoNormal">&nbsp;<o:p>
</o:p>
</p>
<p class="MsoNormal">The Hash include is the standard form for telling the
compiler that you want to include the Iostream.h file.</p>
<p class="MsoNormal">&nbsp;<o:p>
</o:p>
</p>
<p class="MsoNormal">Now on line 2 we have <i>int main(). </i><span style="mso-spacerun: yes">&nbsp;</span>Int
is read as integer, read main() as main function. Without line 2 your program
cannot work. On line 3 and 5 you have these {} braces.</p>
<p class="MsoNormal">&nbsp;<o:p>
</o:p>
</p>
<p class="MsoNormal">Between the 2 braces all your code fits in. Make sure you
enter line 4 exactly as it is. Pay attention to the punctuation.</p>
<p class="MsoNormal"><b>Cout</b>: See cout &#8211; It is the command with which you
display text onto the screen</p>
<p class="MsoNormal">&nbsp;<o:p>
</o:p>
</p>
<p class="MsoNormal">The &lt;&lt; on line 4 is the redirection symbol produced
on most keyboards by holding the shift key and pressing the comma key twice. The
text in between the quotation marks, in the case &#8220;What you do, is what you
get&#8221; is what shall be displayed onto the screen when you run the program.</p>
<p class="MsoNormal">&nbsp;<o:p>
</o:p>
</p>
<p class="MsoNormal">Line 4 ends with a semi colon, don&#8217;t forget to type that,
almost all c++ statements end with that. Now you may finally link, build and
compile the code. Now you receive a message on a black terminal (Dos like):
&#8220;What you do is what you get&#8221;</p>
<p class="MsoNormal">&nbsp;<o:p>
</o:p>
</p>
<p class="MsoNormal">Congrats - You are now officially a programmer and that too
c++.</p>
<p class="MsoNormal">&nbsp;<o:p>
</o:p>
</p>
<p class="MsoNormal">I plan to write more tutorials when I can dedicate some
time after school. If you like this code please give me a good message. I do
need messages occasionally like &#8220;Thanks&#8221;, with all the pressure I face from
school. If you have gained knowledge from this tutorial please make me happy.</p>
</body>
</html>
Original Comments (3)
Recovered from Wayback Machine