constants in c a presentation on department of computer & information technology, m.s.p.v.l....
TRANSCRIPT
![Page 1: Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram](https://reader036.vdocument.in/reader036/viewer/2022082506/56649e9e5503460f94ba02c7/html5/thumbnails/1.jpg)
Constants in C
A Presentation
On
Department of Computer & Information Technology,
M.S.P.V.L. Polytechnic College,
Pavoorchatram.www.ustudy.in
![Page 2: Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram](https://reader036.vdocument.in/reader036/viewer/2022082506/56649e9e5503460f94ba02c7/html5/thumbnails/2.jpg)
Introduction A constant is a quantity whose value does not
change during programming execution. There
are three types of constants they are
Numeric constant
Character constant
String constant
www.ustudy.in
![Page 3: Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram](https://reader036.vdocument.in/reader036/viewer/2022082506/56649e9e5503460f94ba02c7/html5/thumbnails/3.jpg)
Numeric constant A numeric constant is a constant made up of
digits and some special characters. There are
two types of numeric constants. They are
Integer or fixed point constant
Real or floating point constant
www.ustudy.in
![Page 4: Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram](https://reader036.vdocument.in/reader036/viewer/2022082506/56649e9e5503460f94ba02c7/html5/thumbnails/4.jpg)
Integer constant Integer constant is a constant made up of digits
without decimal point. This can have values from -
32,708 to +32,627
Rules
An integer constant is formed with digits 0 to 9.
The constant can be preceded by + or – sign.
No special characters are allowed anywhere in the
constant.www.ustudy.in
![Page 5: Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram](https://reader036.vdocument.in/reader036/viewer/2022082506/56649e9e5503460f94ba02c7/html5/thumbnails/5.jpg)
Real Constant The numbers with decimal point are called real constant or
floating point constant.
A real constant is formed with the digits 0..9 and a decimal point.
The number can be preceded by + or –
The digits before and after the decimal point can be omitted.
No white spaces or special characters are allowed.
Floating point constants can be represented with f for floating and
l for double precision floating point numbers.
The real constants can be expressed in two forms
a) Fraction form
b) Exponential form
www.ustudy.in
![Page 6: Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram](https://reader036.vdocument.in/reader036/viewer/2022082506/56649e9e5503460f94ba02c7/html5/thumbnails/6.jpg)
a)Fractional Form:
The number is written with one decimal point
Example:
2.1567 .761 -34.7 are valid real number in fractional form.
b) Exponential form:
This is useful for representing very large or very small numbers in
magnitude. The general form is
Mantissa e or E exponent
Example:
The number 215.65 can be written in exponent notation as
2.1565e2
The number -0.0000375 can be written as -3.75e-5www.ustudy.in
![Page 7: Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram](https://reader036.vdocument.in/reader036/viewer/2022082506/56649e9e5503460f94ba02c7/html5/thumbnails/7.jpg)
Character Constant
There are two types of character constants.
They are
Direct
Escape sequence
www.ustudy.in
![Page 8: Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram](https://reader036.vdocument.in/reader036/viewer/2022082506/56649e9e5503460f94ba02c7/html5/thumbnails/8.jpg)
Single character constant:
A single character constant consists of a single character
enclosed within single quotes. The single character
constants are stored in memory using their ASCII
equivalent. So every character constant has an integer
value corresponding to its ASCII value. For example the
character 'A' has the equivalent integer ASCII value 65.
Example:
‘$’ ‘e’ ‘9’ are character constants
Here ‘9’ is not equal to numeric 9.
www.ustudy.in
![Page 9: Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram](https://reader036.vdocument.in/reader036/viewer/2022082506/56649e9e5503460f94ba02c7/html5/thumbnails/9.jpg)
Escape Sequences
The Escape Sequences are special characters for
formatting. Character combinations consisting of
a backslash (\) followed by a letter or by a
combination of digits are called "escape
sequences." These special printing characters are
used to make the output readable when printing
characters to the screen, file, or other device
(such as printer).www.ustudy.in
![Page 10: Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram](https://reader036.vdocument.in/reader036/viewer/2022082506/56649e9e5503460f94ba02c7/html5/thumbnails/10.jpg)
Character for Bell (Alert) is .........................'\a'.
Character for Backspace is .........................'\b'.
Character for Horizontal Tab is ...................'\t'.
Character for Vertical Tab is .......................'\v'.
Character for Newline (Line Feed) is ..........'\n'.
Character for Form Feed is .........................'\f'.
Character for Carriage Return is ................'\r'.
Character for Quotation Mark is .................'\"'.
Character for Apostrophe is .......................'\''.
Character for Question Mark is ...................'\?'.
Character for Backslash is ..........................'\\'.
Character for Null is ...................................'\0'.
www.ustudy.in
![Page 11: Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram](https://reader036.vdocument.in/reader036/viewer/2022082506/56649e9e5503460f94ba02c7/html5/thumbnails/11.jpg)
String Constant
A string constant is a sequence of characters
enclosed within double quotation marks. This
can be formed with digits, alphabets and
special characters.
Example:
“C Program” “!Hello****” are valid
string constantswww.ustudy.in