Important alert: (current site time 7/15/2013 4:43:06 PM EDT)
 

article

Tutorial 2

Email
Submitted on: 9/21/2000 9:36:38 AM
By: Amin Patel1 
Level: Beginner
User Rating: By 51 Users
Compatibility: C++ (general), Microsoft Visual C++, Borland C++, UNIX C++
Views: 52609
(About the author)
 
     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.

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
				
Tutorial 2- By: Amin Patel     About Me  
c, c++, c__,tutorial,been,made,give,introduction,programm

 Planet Source Code -                      Start with a prayer to God, that you “Succeed in learning C++"

 
 
Advanced Search
 Tutorials:
Tutorial 1 Tutorial 3


Only at PS Code

Code of the Day
To join the 'Code of the Day' Mailing List click here!

 

Thank you for coming to Planetsourcecode 

Almost every time the teacher gives lesson in school, we might copy everything from the board or make notes over what is taught. There is a similar thing we call in c++, ‘Comments’. Comments can be used for different purposes.

ˇ        The most obvious one, to recall the purpose of the code (Say you are referring to it after 6 months, makes less sense then. If you don’t include a comment.)

ˇ        Helps your computer teacher know what you have actually written. Just kidding.

ˇ        Now this one is an unobvious reason. Sometimes after compiling you might want to remove some line just to see how your program works then, without deleting the actual code.

ˇ        The final one, just a good programming style to express your thoughts.

 

Comments can be written anywhere in the program (Good Feature). They don’t effect your code, unless you comment out something by mistake. 

 

There are two types of comments:

 

  1. C Style: 

/* You can write anything that makes sense here */

 

After the introduction of c++ it just become a norm for programmers to ‘Comment out’, huge parts of their code using this style. The initial part (/*) and the final part(*/) can be on separate lines.

  

  E.g.:

  1. #include <iostream.h>
  2.  int main()
  3. {/*
  4. cout<< “ This whole line gets, commented out!”;*/
  5. }

 

 

 

 

<Warning: The numbered indentation is not to be included with the code while typing. It is only for your convenience>

 

 

  1. C++ Style

 

// After the 2 slashes, you can type anything that makes sense.

 

This comment style is used more often these days but please note that if your comment sentence goes over many lines, please use // on each line at the beginning.

  E.g.:

  1. #include <iostream.h>
  2.  int main()
  3. {
  4. cout<< “How are you I am fine”;
  5. // Line 4 will print 
  6. //“How are you I am fine, to the screen.
  7. // Notice that 
  8. //I placed the 2 slashes on this line too.
  9. }

 

 

 

   
Note: If anything appears wrong, it is due to the incompatibility of the browser.
For compiler compatibility issues please refer to tutorial 3
Users of Netscape have complained regarding misprinting of C++ style comments but I can't verify that since I use IE, but kudos to the Netscape user helping me solve the endless comments problem due to browser incompatibility. 
<-- content_end-->

_______________________________________________________________________

  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.

_______________________________________________________________________

 Tutorial 2 - By: Amin Patel

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | C/ C++ Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising

   C++ - Tutorials

CopyrightŠ 1997 by Exhedra Solutions, Inc. All Rights Reserved.   By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.


Other 3 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
9/21/2000 5:43:15 PMkrane

keep these tutorials coming!@#@! this is what i have been looking for and im sure alot more people are too@#@!
(If this comment was disrespectful, please report it.)

 
9/21/2000 10:56:31 PMAmin Patel

Thank you very much!
(If this comment was disrespectful, please report it.)

 
10/5/2000 10:43:52 PMIan Ippolito

I've just removed a slew of off-topic comments.
Ian
PSCode Admin
(If this comment was disrespectful, please report it.)

 
10/8/2000 9:30:58 PMSebastian

Very nice and clean article, just can't wait until the little more advanced stuff comes :-)
(If this comment was disrespectful, please report it.)

 
10/9/2000 9:34:16 AMKoeter

Nice Tut ! I#d like to see more :o)
(If this comment was disrespectful, please report it.)

 
10/16/2000 10:21:00 AMRoland

Nice tutorial. I am not new to programming, but I am new to C++. The few books I've picked up on the subject are indepth, but lack the 'being schooled' programmer's perspective. Keep up the good work and I'll be tuning in for future tutorials!
(If this comment was disrespectful, please report it.)

 
1/21/2001 7:59:24 PMCraig

Good approach for beginners!
Your tutorial taught me how to use my command-line compiler (although I now use Dev-C++[great IDE])
I think some links would be helpful, as well as some terminology so the people you start off can learn more.

PS. do you know of a good non-MFC Win32 API tutorial?
(If this comment was disrespectful, please report it.)

 
1/21/2001 8:01:46 PMCraig

Good approach for beginners!
Your tutorial taught me how to use my command-line compiler (although I now use Dev-C++[great IDE])
I think some links would be helpful, as well as some terminology so the people you start off can learn more.

PS. do you know of a good non-MFC(vc++) Win32 API tutorial?
(If this comment was disrespectful, please report it.)

 
9/25/2001 9:03:28 PMDaza

These tutorials r great i have learnt stacks. keep them coming. 10/10
Daza
(If this comment was disrespectful, please report it.)

 
10/1/2001 7:54:17 AMTore

Thanks for the tutorial.
"Moo i am a flying cow mooo", .
(If this comment was disrespectful, please report it.)

 
11/11/2001 3:09:14 PMimn0thing

this tutorial does nothing but show how to use comments. and besides that, your explanation is ridiculously poor. why are people voting anything above 1 for your tutorials?
(If this comment was disrespectful, please report it.)

 
7/13/2002 10:20:06 AMjohn gibson

I have done a fair bit of c and vb and am now about to learn c++. I've already started reading and experimenting a bit and with my knowledge of c, there was nothing new here for me. However, this is a fact, not a negative comment. It seems amazing to me how a school pupil can give an outline of the basics in such a clear and concise way where many (or almost all) of the books I've looked at are so confusing. This will be a great help for those without pre-existing knowledge of c or c++. Well done.
(If this comment was disrespectful, please report it.)

 
1/30/2003 2:55:54 AM

Reading the comments that people have made, it seems as though no one has even read the tutorial. A clear and concise outline of the basics? Taught me how to use my command-line compiler? Good grief. And don't use #include , not in your code and certainly not in a tutorial. You should have and .
(If this comment was disrespectful, please report it.)

 
1/30/2003 2:57:07 AM

\ and \.
(If this comment was disrespectful, please report it.)

 
1/30/2003 2:58:49 AM

Great. I meant, you should have (left angle bracket) iostream (right angle bracket) and (left angle bracket) ostream (right angle bracket) (no spaces).
(If this comment was disrespectful, please report it.)

 
3/25/2003 11:44:52 AM

Im not that new to c++ programming and i know the mateiral you are discussing...but i like your approach. Lots of tutorials and books etc... dont teach it right. They make it sound hard...and complicated...self teaching this stuff gets hard when the teachers are making it difficult and technical
(If this comment was disrespectful, please report it.)

 
7/2/2003 11:37:45 AMJustin W.

This is a great tutorial but I sort of think you put too much effort into the whole template of pscode thing. This tutorial could have been written in just a few lines. Hope there are more tutorials coming.
(If this comment was disrespectful, please report it.)

 
9/2/2003 4:20:40 AM

Fantastic Tut, Keep up the good work!
(If this comment was disrespectful, please report it.)

 
10/17/2003 5:49:15 PM

Your tutorials are ausome make more. i just started they helped me a lot
(If this comment was disrespectful, please report it.)

 
4/2/2007 12:23:38 PMset

i dont get it is it just me or when i run the program it close the same second how to change this
btw i give you 4 for not rtping that
(If this comment was disrespectful, please report it.)

 
7/19/2008 12:50:02 PMKaito-kun

Well, It was very very easy to understand..Inputting notes into your command lines ready does make it easier to know what it means with a quick glance

good work 5/5
(If this comment was disrespectful, please report it.)

 
4/28/2009 5:28:15 PMAdila Afshan

Nice

(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.