Differences

This shows you the differences between two versions of the page.

Link to this comparison view

programmers_guide:literals [2014/06/03 17:47] (current)
Line 1: Line 1:
 +====== Literals ======
 +===== Literal Constants =====
 +When a value is actually written in the program it is constant. ​ Perhaps it would be more correct to such a value a '​Literal Constant'​. ​ In practice the term '​Literal'​ is used for short.  ​
 +
 +Literals are either numeric or character strings. We have already seen examples of both.  In the following example:
 +
 +  put "​Please enter your name:"
 +
 +the text enclosed in those quotes is a literal and is constant. ​ It never changes while the program is being run and it is the same every time the program is run.  ​
 +
 +Similarly if in a program you need to multiply a value by 3, then 3 is a constant because it will always be 3 in that part of the program.
 +
 +  x = y * 3
 +
 +
 +===== Literals in Expressions =====
 +Literals may be used anywhere in an expression. ​ For example.
 +  put "The number"​ 7 "is my lucky number"​
 +  put "The value of PI is" 3.14159265
 +will show:
 +  The number 7 is my lucky number
 +  The value of PI is 3.14159265
 +
 +===== String Literals =====
 +  put "The value of PI is" 3.14159265
 +In the above example the text "The value of PI is" is a string literal constant or string literal for short.
 +===== Numeric Literals =====
 +  put "The value of PI is" 3.14159265
 +In the above example the value //​3.14159265//​ is a numeric literal constant or numeric literal for short.
 +
 +
 +===== Page Links =====
 +
 +|< 100% 35% - 28% - 35% >|
 +| <= [[data]] ​ ^ |  [[start]] ​ ^ |  [[constants]] => |
  

programmers_guide/literals.txt · Last modified: 2014/06/03 17:47 (external edit)