The C++Course provides a general introduction to programming in C++. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details.


A value is one of the fundamental things---like a letter or a number---that a program manipulates. The only values we have manipulated so far are the string values we have been outputting, like "Hello, world.". You (and the compiler) can identify string values because they are enclosed in quotation marks.

There are other kinds of values, including integers and characters. An integer is a whole number like 1 or 17. You can output integer values the same way you output strings:

  cout << 17 << endl;

A character value is a letter or digit or punctuation mark enclosed in single quotes, like 'a' or '5'. You can output character values the same way:

  cout << '}' << endl;

This example outputs a single close squiggly-brace on a line by itself.

It is easy to confuse different types of values, like "5", '5' and 5, but if you pay attention to the punctuation, it should be clear that the first is a string, the second is a character and the third is an integer. The reason this distinction is important should become clear soon.

Last Update: 2005-11-21