Integer and Floating Point Literals

This lesson will cover integer and floating point literals and their syntax rules.

Literals #

Programs achieve their tasks by manipulating the values of variables. They produce new values by using them with functions and operators.
Some values, however, need not be modified during the execution of the program. Instead, they are used as-is in the source code. For example, the floating point value 0.75 and the string value "Total price: " below are not calculated by the program:

discountedPrice = actualPrice * 0.75;  
totalPrice += count * discountedPrice;  
writeln("Total price: ", totalPrice);

Such values, which directly typed into the source code, are called literals. We have used string literals in the programs so far. Now, we will see other types of literals.

Get hands-on with 1200+ tech skills courses.