Literal Constants

 Abdessalam Go
0

Literal Constants

Definition of Literal Constants :

Litreal constants is a value such as number , string or character , and litreal constant means  how we can write the value of an constant  or variable ? and what is the different formats of  some value ?



in C language we have four different literal constants :
- integer literal .
- float literal .
- double literal .
-character literal .

Classification of literal constants :

In C language we can write literal constant with three different ways such as integer literal constant , literal qualifiers , character literal constant .

Integer Literal Constants :

To write an value of integer type (variable or constant) we must choose one of the following statements :
example:
a=42 ;  // decimal integer
a=0x2a;  // hexadecimal integer
a=052:  // octal integer
a=0b101010; // binary integer

Literal Qualifiers :

Literal  Qualifiers  are group of symbols used to force compiler to treat them as a specific data type .

we use :
.U or u for unsigned 
.L or l for long 
.F or f for float
.The U and L suffixes may be combined to create an unsigned long literal .


character literal constant :

A character is just a singl charchter constant to refer to number or alphabet , ther are many ways to write or represent a literal constant character .
. char inside  single quote ex : 'a'  'f' 'g' '/' etc.
. escape sequence character ex : '/n' .
. integer Ascii format ex : '65' refer and represented 'A' in ascii .
. in list below we have some escape sequence  character  :
escape character description
\0 NULL
\a Alert
\n New line
\r Carriage return
\t Horizontal tab
\\ Backslash
\'   single quotes
\"   Double quotes
Tags

Post a Comment

0Comments
Post a Comment (0)

Cookies Consent

This website uses cookies to offer you a better Browsing Experience. By using our website, You agree to the use of Cookies

Learn More