Tutorial 3
This tutorial has been made for new c++ programmers. Unfortunately their are many great minds out there but they don't have access to free and quality c++ tutorials.
AI
Résumé par IA: 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.
Code source
<body>
<table CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="673" HEIGHT="18">
<tr>
<td HEIGHT="18" ALIGN="LEFT" NOWRAP="1" BACKGROUND="file:///E:/MYDOCU~1/MSNUK~1/images2/masthead_bg.gif" BGCOLOR="#636563" linkattrib="BACKGROUND" width="170"><font face="verdana,arial,helvetica" size="-2" color="#FFCC00"><b>Tutorial
3- By: Amin Patel </b></font><small> </small></td>
<td HEIGHT="18" ALIGN="CENTER" NOWRAP="1" BACKGROUND="file:///E:/MYDOCU~1/MSNUK~1/images2/masthead_bg.gif" BGCOLOR="#636563" linkattrib="BACKGROUND" width="351"> </td>
<td HEIGHT="18" ALIGN="RIGHT" NOWRAP="1" BACKGROUND="file:///E:/MYDOCU~1/MSNUK~1/images2/masthead_bg.gif" BGCOLOR="#636563" linkattrib="BACKGROUND" width="146"><a HREF="http://www.planetsourcecode.com/xq/ASP/lngAuthorId.49697/lngWId.3/qx/vb/authors/ShowAuthorBio.htm"><font FACE="verdana,arial,helvetica" SIZE="-2" COLOR="#FFFFFF"><b>About
Me </b></font></a> </td>
</tr>
<tr>
<td COLSPAN="3" width="671"><img SRC="images2/masthead_break.gif" WIDTH="671" HEIGHT="1"></td>
</tr>
</table>
<table CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="671" HEIGHT="57">
<tr>
<td VALIGN="MIDDLE" ALIGN="LEFT" BGCOLOR="#00339A" WIDTH="132" ROWSPAN="2"><img alt="c, c++, c__,tutorial,been,made,give,introduction,programm" border="0" height="97" src="http://www.planetsourcecode.com/vb/images/logos/PscLogo1.jpg" width="132"></td>
<td VALIGN="TOP" ALIGN="LEFT" BGCOLOR="#993366" width="525">
<p align="left"><font face="Kristen ITC" color="#FFFFFF"> Planet
Source Code - <font size="1">
</font></font><font size="1">Start with a prayer to God, that you
“Succeed in learning C++"</font></td>
<td VALIGN="MIDDLE" ALIGN="RIGHT" BGCOLOR="#00339A" width="8"> </td>
</tr>
<tr>
<td VALIGN="BOTTOM" ALIGN="RIGHT" BGCOLOR="#00339A" WIDTH="535" COLSPAN="2"> </td>
</tr>
</table>
<table ALIGN="LEFT" CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="672" HEIGHT="85%">
<tr>
<td VALIGN="TOP" WIDTH="165">
<table WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0" HEIGHT="42">
<tr>
<td VALIGN="MIDDLE" ALIGN="CENTER" BGCOLOR="#FFFFFF"><center><a href="http://www.planetsourcecode.com/vb/scripts/search.asp?lngWId=3">Advanced
Search</a></center></td>
</tr>
<tr>
<td BGCOLOR="#804000"><img SRC="images2/spacer.gif" WIDTH="100%" HEIGHT="1" BORDER="0"></td>
</tr>
</table>
<table WIDTH="168" CELLPADDING="3" CELLSPACING="0" BORDER="0" height="192">
<tr>
<td VALIGN="MIDDLE" WIDTH="152" height="67">
<p align="center"> </p>
<b>Previous Tutorials</b>:</td>
</tr>
<tr>
<td BGCOLOR="#DDDDDD" ALIGN="LEFT" width="80" height="86">
<table CELLPADDING="2" CELLSPACING="0" width="139">
<tr>
<td VALIGN="BOTTOM" width="63"><a href="http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?lngWId=3&txtCodeId=769">Tutorial
1</a></td>
<td VALIGN="MIDDLE" width="64"><a href="http://www.planetsourcecode.com/xq/ASP/txtCodeId.773/lngWId.3/qx/vb/scripts/ShowCode.htm">Tutorial
2</a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td HEIGHT="34" width="72"></td>
</tr>
</table>
<p align="left"><br>
<font face="Arial Rounded MT Bold"><b><span class="h2tv">Only at PS Code</span>
- </b></font>
<p><font size="2">Code of the Day</font><br>
To join the <a href="http://www.planetsourcecode.com/vb/CodeOfTheDay/signup.asp?lngWId=3">'Code
of the Day'</a> Mailing List <a href="http://www.planetsourcecode.com/vb/CodeOfTheDay/signup.asp?lngWId=3">click</a>
here!</p>
<p> </p>
<div align="center">
<center>
<table border="0" width="100%">
<tr>
<td width="100%"><i>Thank you for coming to Planetsourcecode</i> </td>
</tr>
</table>
</center>
</div>
</td>
<td WIDTH="1" BGCOLOR="#AAAAAA"><img SRC="images2/spacer.gif" WIDTH="1" HEIGHT="85%" BORDER="0"></td>
<td></td>
<td VALIGN="TOP" WIDTH="491"><b><font size="4">Style</font></b>: In the
first tutorial some people had pointed out that I had not declared <b>main()</b>
to return void, this is no longer a standard expected from programmers.
Get <b>main()</b> to return <font color="#0000FF">int</font> & simply <font color="#0000FF">return</font>
0; as the last line in <b>main()</b>.<br>
<!-- content_start-->
<table CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%">
<tr>
<td VALIGN="TOP">
<table CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="280">
<tr>
<td WIDTH="100%">
<p align="left"><font size="4"><img SRC="images2/spacer.gif" WIDTH="4" HEIGHT="1" BORDER="0"><b>Note</b></font>:
According to the latest standards <<b>iostream.h</b>> is
not required it can be simply written as <<b>iostream</b>>,
with the standard code that shall be used through out the
tutorial (I hope!).
<p align="left">If the standard code in the tutorial does not work
on your compiler and you still wish to use <<b>iostream</b>>
instead of <<b>iostream.h</b>> just add a line</p>
<p><center><font color="#0000FF">using namespace</font>
std; </center></p>
<p align="left">& if this does not work you have an old
compiler which cannot work with these standards.</p>
<center>
<p>
<table border="0" width="100%" height="173">
<tr>
<td width="100%" height="1"> <!-- Begin Search Code -->
<form METHOD="POST" ACTION="http://www.musalman.net/cgi-bin/texis.cgi/webinator/musalman/">
<div align="center" style="width: 324; height: 67">
<b> </b> Now Pay attention, with a
little explanation and review of the first tutorial
we shall proceed. Some people requested for the
theoretical details.</FORM>
</div>
</td>
</tr>
<tr>
<td WIDTH="100%" height="136">- <b><u>Preprocessor</u></b>
<p>Preprocessing is done when the #include command is
used to add header files. The actual preprocessing is
done much before the compiler reaches the <i>code</i>
section of your program. The #include command is one
of the possible actions of preprocessing.</p>
<p>All Preprocessing is done with #(Hash/Pound Symbol)</p>
<p>- <b><u>#include</u></b></p>
<p>This a directive to the preprocessor, with the help
of the " Include Hash/Pound " the file after
the directive s read.</p>
<p>Eg: <font color="#0000FF">#include</font> <<b>filename</b>>
or <font color="#0000FF">#include</font> <<b>filename.h</b>> </td>
</tr>
<tr>
<td WIDTH="100%" height="66">- <b><u>IO</u></b>
<p>When generally the topic of input is raised, the
first thought that comes to a person's mind is that
input means input from a keyboard, mouse, joystick,
etc and is outputted to a device such as a disk, monitor
(screen) or printer & this thought is technically
correct; in explaining the concept of input-output.</p>
<p>- Input is done in streams of bytes or a sequence
from devices (e.g.. keyboard, mouse, joystick,
etc). </p>
<p>-In Output bytes flow from the output devices.</p>
<p>A program is divided into bits, bytes, a byte may
represent ASCII characters.</p>
<p>The C++ iostream library has many I/O capabilities
but for now we are only concerned with a few.</p>
<p>The <<b>iostream</b>> header file defines the
<b>cin</b>, <b>cout</b> objects.</p>
<p> </td>
</tr>
</table>
</center></td>
<td WIDTH="10"></td>
<td VALIGN="TOP">
<table CELLPADDING="3" CELLSPACING="0" BORDER="0">
<tr>
<td VALIGN="TOP" ALIGN="CENTER"></td>
<td WIDTH="5"><img SRC="images2/spacer.gif" BORDER="0" width="1" height="1"></td>
<td VALIGN="TOP" ALIGN="CENTER"></td>
</tr>
<tr>
<td VALIGN="TOP" ALIGN="CENTER"></td>
<td WIDTH="5"></td>
<td VALIGN="TOP" ALIGN="CENTER"></td>
</tr>
<tr>
<td VALIGN="TOP" ALIGN="CENTER"></td>
</tr>
</table>
</td>
</tr>
</table>
<hr NOSHADE="TRUE" SIZE="1" COLOR="#CCCCCC" WIDTH="100%" ALIGN="LEFT">
<table CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%" height="264">
<tr>
<td VALIGN="TOP" height="262">
<table CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%">
<tr>
<td VALIGN="TOP" WIDTH="50%"> I think the theoretical
explanation of the beginning of a program should be
enough for now. Let us now get to the 'real' juicy
part of programming. (Duh - Writing the code)
<p>- <u><b>2 Input/Output Objects</b></u> ( In
relation to the tutorial)</p>
<p><b>cout </b>(It ain't pronounced as Cowt, its
pronounced as C Out)</p>
<p>The cout operator has already been explained in <a href="http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?lngWId=3&txtCodeId=769">tutorial
1</a> but here is a brief review + additions.</p>
<p>cout is a keyword, which is exclusively reserved
for C++ defined purposes. It is used to output data
info to the standard output device.</p>
<p>cout<<"This is Text"; </p>
<p>By the way <a href="http://www.planetsourcecode.com/xq/ASP/txtCodeId.773/lngWId.3/qx/vb/scripts/ShowCode.htm">Comments</a>(
// ) have been explained previously. </p>
<p><font color="#008000">// << is known as
stream insertion operator. </font></p>
<p><font color="#008000">// "This is Text"
is displayed to the screen.</font></p>
<p><font color="#008000">//The << is also known
as left shift operator, it is used after the cout
command.</font></p>
<p>cout<<text; </p>
<p><font color="#008000">//The data from a variable
text is displayed to the screen.</font></p>
<p><font color="#008000">//Variables have not yet been
explained at this point.</font></p>
<p> </p>
<p> </p>
<p> </td>
<td WIDTH="10"> </td>
<td VALIGN="TOP" WIDTH="50%"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td VALIGN="TOP" height="2">
<table CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%">
</table>
</td>
</tr>
</table>
Now to explain the next topic cin & datatype (int), we shall
attempt to understand by studying a simple program. - Adding 2
integers<br>
<table CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="497">
<tr>
<td valign="top" align="left" bgcolor="#E8E8F7" width="262" height="29">Non
Standard Version
<p><font color="#0000FF">#include</font> <<b>iostream</b>><br>
<br>
i<b><font color="#0000FF">nt</font></b> main()<br>
{<br>
<font color="#0000FF"> int</font> one, <font color="#0000FF"> int</font> two,
<font color="#0000FF"> int</font> sum;<br>
cout<<"Please enter the first number"; //Requests for first integer<br>
cin>>one; <font color="#008000"> //accepts first integer</font><br>
<br>
cout<<"Please enter the second number"; <font color="#008000"> //Requests for second integer</font><br>
cin>>two; <font color="#008000"> //accepts second integer.</font><br>
<br>
sum = one + two; <font color="#008000"> // one & two get added and the value gets assigned to sum.</font><br>
cout<<"The sum:"<<sum; <font color="#008000"> //sum of 2 int's is displayed</font><br>
<br>
<font color="#0000FF"> return</font> 0; <font color="#008000"> //program has ended</font><br>
}</td>
</tr>
<tr>
<td height="34" width="262"></td>
</tr>
<tr>
<td valign="top" align="left" bgcolor="#fffff0" width="262" height="44">Standard
Version
<p><font color="#0000FF">#include</font> <<b>iostream</b>><br>
</p>
<p><font color="#000080">using</font> std::cout;<br>
<font color="#000080">using</font> std::cin;</p>
<p><br>
i<b><font color="#0000FF">nt</font></b> main()<br>
{<br>
<font color="#0000FF"> int</font> one, <font color="#0000FF"> int</font> two,
<font color="#0000FF"> int</font> sum;<br>
cout<<"Please enter the first number"; //Requests for first integer<br>
cin>>one; <font color="#008000"> //accepts first integer</font><br>
<br>
cout<<"Please enter the second number"; <font color="#008000"> //Requests for second integer</font><br>
cin>>two; <font color="#008000"> //accepts second integer.</font><br>
<br>
sum = one + two; <font color="#008000"> // one & two get added and the value gets assigned to sum.</font><br>
cout<<"The sum:"<<sum; <font color="#008000"> //sum of 2 int's is displayed</font><br>
<br>
<font color="#0000FF"> return</font> 0; <font color="#008000"> //program has ended</font><br>
}<br>
</td>
</tr>
<tr>
<td VALIGN="TOP" WIDTH="262"></td>
</tr>
<tr>
<td VALIGN="TOP" width="330"></td>
<td WIDTH="1"></td>
<td VALIGN="TOP" width="162"></td>
</tr>
</table>
<!-- content_end-->
</td>
</tr>
<tr>
<td VALIGN="TOP" WIDTH="671">
<table WIDTH="673" CELLPADDING="0" CELLSPACING="0" BORDER="0">
<tr>
<td COLSPAN="2" width="671">
<hr NOSHADE="TRUE" SIZE="1" COLOR="#CCCCCC" WIDTH="671" ALIGN="LEFT">
<p class="MsoNormal">_______________________________________________________________________</p>
<p class="MsoNormal"> If you like this code please
give me a good message. If you have gained some
knowledge from this tutorial please make me happy, by giving
me an “excellent rating”. That's all I ask.</p>
<p class="MsoNormal">_______________________________________________________________________</p>
<pre> <b>Tutorial</b> 3 - <b>By</b>: <b>A</b>min <b>P</b>atel</pre>
<p> </td>
</tr>
<tr>
<td VALIGN="TOP" WIDTH="1"></td>
<td VALIGN="TOP" WIDTH="668" ALIGN="CENTER">
<p align="left"><font size="1"><a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/scripts/BrowseAllCategories.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" style="COLOR: #000080" target="_top">Categories</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/Tutorial/default.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" target="_top">Articles
and Tutorials</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/scripts/search.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" target="_top">Advanced
Search</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/Bookstore/default.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" style="COLOR: #000080" target="_top">Recommended
Reading</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/authors/determine_author_type.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" target="_top">Upload</a> | <a href="http://www.planetsourcecode.com/xq/ASP/grpCategories.-1/optSort.DateDescending/txtMaxNumberOfEntriesPerPage.10/blnNewestCode.TRUE/blnResetAllVariables.TRUE/lngWId.3/qx/vb/scripts/BrowseCategoryOrSearchResults.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" style="COLOR: #000080" target="_top">Newest
Code</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/contest/ContestAndLeaderBoard.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" target="_top">Code
of the Month</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/CodeOfTheDay/signup.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" style="COLOR: #000080" target="_top">Code
of the Day</a> | <a href="http://www.planetsourcecode.com/xq/ASP/grpCategories.-1/txtMaxNumberOfEntriesPerPage.10/blnTopCode.True/blnResetAllVariables.TRUE/lngWId.3/qx/vb/scripts/BrowseCategoryOrSearchResults.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" style="COLOR: #000080" target="_top">All
Time Hall of Fame</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/contest/ContestInfo.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" style="COLOR: #0000ff" target="_top">Coding
Contest</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/jobs/SearchJobs.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" target="_top">Search
for a job</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/jobs/PostJob.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" target="_top">Post
a Job</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/discussion/default.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" style="COLOR: #000080" target="_top">Ask
a Pro Discussion Forum</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/chat/chat.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" target="_top">Live
Chat</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/feedback/feedback.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" target="_top">Feedback</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/authentication/MyPlanetSourceCode/CustomizeInfo.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" style="COLOR: #000080" target="_top">Customize</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/default.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" style="COLOR: #000080" target="_top">C/
C++ Home</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId./qx/default.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" target="_top">Site
Home</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/scripts/OtherLinks.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" target="_top">Other
Sites</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/about/AboutTheSiteAndAuthor.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" style="COLOR: #000080" target="_top">About
the Site</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/feedback/feedback.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" target="_top">Feedback</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/LinkToUs/default.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" target="_top">Link
to the Site</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/about/Awards.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" target="_top">Awards</a> | <a href="http://www.planetsourcecode.com/xq/ASP/lngWId.3/qx/vb/advertisement/scripts/rates.htm" onmouseout="javascript:this.style.color='#000080'" onmouseover="javascript:this.style.color='#0000FF'" target="_top">Advertising</a></font><br>
<br>
</p>
<p align="left"> <b><font size="4">C++ </font></b>
- Tutorials<br>
<br>
<center><font face="verdana,arial" size="1">Copyright© 1997
by <a href="http://www.exhedra.com">Exhedra Solutions, Inc.</a>
All Rights Reserved. By using this site you
agree to its <a href="http://www.planetsourcecode.com/vb/scripts/TermsAndConditions.asp?lngWId=3">Terms
and Conditions.</a> Planet Source Code (tm) and
the phrase "Dream It. Code It" (tm) are trademarks
of Exhedra Solutions, Inc.</font></center></p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</table>
</body>
Commentaires originaux (3)
Récupéré via Wayback Machine