article

Tutorial 2

Email
Submitted on: 1/1/2015 12:53:00 PM
By: Amin Patel1 (from psc cd)  
Level: Beginner
User Rating: By 51 Users
Compatibility: C++ (general), Microsoft Visual C++, Borland C++, UNIX C++
Views: 1250
 
     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.

 
				
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 2 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


 There are no comments on this submission.
 

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.