Professional Documents
Culture Documents
programmerdouts.blogspot.com/2019/06/constants-in-c.html
Constants
Constants are identifiers that represent fixed values
when we have to keep an variable unchange through out the
the program then we use constants
it can done by using the "const" keyword
Syntax: const data-type constant_name = value;
Ex: const float pi = 3.14;
another method is using macros, macros we will be studying deeply in further
modules.
Syntax: #define constant_name = value;
Ex: #define pi = 3.14;
main(){
Output:
constant value declaration through constant keyword is 2.48
constant value through macros declaration is 3.14
Escape Sequence in C
Escape sequences are used in the programming languages C and C++, and their design was
copied in many other languages such as Java and C#. An escape sequence is a sequence of
characters that does not represent itself when used inside a character or string literal, but is
translated into another character or a sequence of characters that may be difficult or
impossible to represent directly. In C, all escape sequences consist of two or more
1/4
characters, the first of which is the backslash, \ (called the "Escape character"); the
remaining characters determine the interpretation of the escape sequence. For example, \n
is an escape sequence that denotes a newline character.
Constant Meaning
\" Insert the double quote character in the text at this point
Output:
HelloWorld
2/4
Output:
Hello World
Print the Message hello world in which "world" is print in the next line.
Escape Sequence:"\n"
Output:
Hello
World
Output:
"HelloWorld"
3/4
4/4