ποΈ Introduction
Hello everyone!
In the previous lesson, we understood what a constant is β a value that cannot change during program execution.
Now the next question is:
π Are all constants the same?
π Or are there different types of constants in C language...Read More
πΉ Step 1: What Are Types of Constants?
In C programming, constants are mainly divided into the following types:
- Integer Constants
- Floating-Point Constants
- Character Constants
- String Constants
- Enumeration Constants
Each type represents a different kind of fixed...Read More
πΉ Step 2: Integer Constants
Integer constants are whole numbers without any decimal point.
Examples:
10
0
-25
1000 These constants represent integer values.
They can be:
Positive (25)
Negative (-50)
Zero (0)
Integer constants are commonly used for...Read More
πΉ Step 3: Floating-Point Constants
Floating-point constants are numbers that contain a decimal point.
Examples:
3.14
0.5
-2.75
100.00
These constants represent real numbers.
They are used when precision or fractional values are...Read More
πΉ Step 4: Character Constants
Character constants represent a single character enclosed in single quotation marks.
Examples:
'A'
'b'
'5'
'#'
Important points:
Only one character is allowed...Read More
πΉ Step 5: String Constants
String constants are a group of characters enclosed in double quotation marks.
Examples:
"Hello"
"C Programming"
"2026"
"Nepal"
Important points:
Must be enclosed in double quotes.
Can contain letters, numbers, and symbols...Read More
πΉ Step 6: Enumeration Constants
Enumeration constants are defined using the enum keyword.
They represent a set of named integer constants.
For example:
Days of the week:
MON
TUE
WED
Internally, these are stored as integers starting...Read More
πΉ Step 7: Symbolic Constants
Apart from the above types, C also allows symbolic constants using:
const keyword
define preprocessor directive
For example:
PI
MAX
LIMIT
These are named constants that represent fixed values...Read More
π Summary of Types of Constants
Letβs quickly revise:
Integer Constants β Whole numbers
Floating-Point Constants β Decimal numbers
Character Constants β Single character in single quotes...Read More
Top comments (0)