0% found this document useful (0 votes)
70 views4 pages

What Are Literals

Literals represent fixed values in source code such as integers, floating point numbers, strings, booleans, and characters, and are used to assign particular values within a program. The document discusses different types of literal constants including integer, floating-point, character, string, and boolean literals and provides examples of each type of literal. It also explains the difference between character and string literals in terms of enclosing quotation marks and composition of multiple characters.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views4 pages

What Are Literals

Literals represent fixed values in source code such as integers, floating point numbers, strings, booleans, and characters, and are used to assign particular values within a program. The document discusses different types of literal constants including integer, floating-point, character, string, and boolean literals and provides examples of each type of literal. It also explains the difference between character and string literals in terms of enclosing quotation marks and composition of multiple characters.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

What are Literals?

  is a notation for representing a fixed value in source code. Almost all programming


languages have notations for atomic values such as integers, floating-point numbers,
and strings, and usually for booleans and characters; some also have notations
for elements of enumerated types and compound values such as arrays, records,
and objects. An anonymous function is a literal for the function type.
 Literals are used as particular values within the source code of a program.
 For Example: a=5; 5 in this piece of code is a literal constant.

Literal Constants
 Literal constants can be :
 Integer numerals
 Floating-point numerals
 Characters
 Strings
 Boolean values

Integer numerals
 Integer numerals are constant and are also called Decimal numerals.
 For Example:
 235
 612
 18
 29
Floating-point numerals
 Floating-point numerals are numbers with decimals, fraction, and/or exponents.
 For example:
 3.14159 // 3.14159
 6.02e23 // 6.02 x 10 ^23

Character and String literals


 Character and String literals are non-numeric constant literals like:
 ‘z’- character
 ‘j’- character
 ‘a’- character
 “Jasmin”- string
 “Hello World”- string

Difference between Character and String


 Character represents a single character constant.
 While a String literal is composed of several characters.
 A Character is enclosed with single quotation marks (‘f’).
 String literal has double quotation marks(“Hello world“).

Boolean Literals
 Boolean Literals can have either a true or false.
 Example:
<< true << '\n‘
false << '\n‘
 Output:
True-1
False-0
Group
Report
Submitted by: Group 3

Members:
Kahn Xavier Nathaniel Domingo
John Benedict Alcantara
Lance Tristan Belen
John Michael Ilagan
Abigail Daaca
Rein Julien Tandang
Angela Kate Bundalian
Juliann Fandialan
Trisha Marie Pacia
Daniel Luis Codilla
Programming
Using Visual
Studio

You might also like