Comments


Comments in C++ are only a little different than the ones you've used in Pascal. The big difference is that instead of { and } or (* and *) as the beginning and end of comments, you use /* and */. Let's try it out!

/*

This is a big comment

*/

/* This is a small comment */

C++ also defines another way to comment out a line. If you say /, everything to its right on that line only is commented out. So, if you had:

/* This is a comment */
/* This is a comment, too */
/* And Yes, I'm a comment. Are you a comment? */

You could turn it into:

/ This is a comment
/ This is a comment, too
/ And Yes, I'm a comment. Are you a comment?

This is sometimes easier when you want to just put a small comment off to the right. Feel free to use either one.


Table of Contents

The Big Picture | Comments | Variables | More on Variables
Variable Operations | Making Choices | More on if | Using else
Using switch | The while Loop | The do..while Loop | Constants
The for Loop | More on the for Loop | Exercises