UNIT 2 2.4 Constants Flashcards
refer to fixed values that may not be altered by the program. Turbo C constant
can be any of the basic data types or known as Literal Constants.
Constants
constants that are enclosed between single quotes.
Character constants
Example
‘a’, ‘%%’ , ‘P’ , ‘U’, ‘P’
constants that are specified as number without fractional components.
Integer Constants
Example
10, -100, 25, 3179
Constants that required the use of decimal point followed by the number’s
fractional components.
Floating-point constant
Example
11.123, 1.25, 5.00
constant consists of a phrase contained/enclosed within double quotes. These constants are used in printf statements to introduce text messages into a
program.
String constant or Literal string constant
Example
“PUP”, “BSIT”, “BSCS”
These constants are defined using a #
defined declaration at the beginning of the program. This declaration is introduced by the word #
defined follow by a constant name and its value.
Declared Constants
Example # define total 100 # define orange 17.50 # define letter ‘M’ # define x 5 # define word “hello”