Friday, March 27, 2020

What is Floating-point literal ?




 Floating-point literal                                                                                          A Floating-point is a numeric literal that has a fractional form or an exponent form.
For Example 
                      -2 ,  0.0000342 ,  -0.33E5 etc
Note  E-5 = 10 -5

Character   

A character literal is created by enclosing a single a single character inside quotation marks. 
For example : 'a' 'b' '3' 'D' '{' etc 

Escape Sequence

Sometimes, it is necessary to use characters that cannot be typed or has special meaning in C programming. For example : newline(enter) ,tab, question mark etc .
In order to use these characters, escape sequence are used. 

           Escape Sequence

|     \b                                 Backspace
|     \f                                  Form feed
|     \n                                 Newline
|     \r                                  Return
|     \t                                  Horizontal tab
|     \v                                 Vertical tab
|     \\                                 Backslash
|     \'                                  Single Quotation mark
|     \"                                 double Quotation mark 
|    \?                                 Question mark
|    \0                                 Null Character

For example : \n is used for newline . The backlash  \ causes escape from the normal way the characters are handled by the compiler.

Strings literals

A string literal is a sequence of character enclosed in double-quote.
For example 
"good"       \\ String constant 
" "              \\ Null string character 
"z"             \\ String constant having single character
"Earth is round \n"         \\ Print string with a newline

Constant

If you want to define a variable whose value cannot be  changed, you can use the constant keyword.
For example : const double PI =3.14;
Notice : PI  Symbolic constant; its value cannot be changed. 

Constant double PI = 3.14;   \\ Constant value 
PI = 2.4   \\ Error   

You can also define a constant using the define  preprocessor directive. 

You will learn about C Macros tutorial .

0 comments:

Post a Comment

Recent Posts