Tuesday, July 22, 2008

What are Constants in C++?

Constants are expressions with a fixed value or the value that cannot be changes.

Literals

Literals are used to express particular values within the source code of a program. We have previously used these previously to provide concrete values to variables or to express messages we wanted our programs to print out.

F example, when we wrote:

int x=5;

the 5 in this piece of code was a literal constant.

The Literal constants can be divided in Integer Numerals, Floating-Point Numerals, Characters, Strings and Boolean Values.

No comments: