Understanding Constants and Keywords in C: A Comprehensive Guide
C Character Set – Constants and keywords in C
A character denotes any alphabet, digit or special symbol used to represent numbers and special characters allowed in C.
- Alphabets: A, B, C,….. Z a, b, c……z
- Numeric Digits:0,1,2,3,4,5,6,7,8,9.
Special Characters
+ | – | * | / | = | % |
& | # | ! | ? | ^ | “ |
‘ | ~ | \ | | | < | > |
( | ) | [ | ] | { | } |
: | ; | . | , | – |
Constants
Constants represent fixed values. That means their value will not change in the program.
Integer Constants
- An integer constant must have atleast one digit.
- It must not have any decimal point.
EX:50
+890
-9609
Real Constants
- Real constants are often called Floating point constants.
- Real constants must have atleast one digit.
- It must have a decimal point.
- It could be either positive or negative.
EX:+564.98
890.0
-65.987
+3.2e-5
Character Constants
Character constant is a single alphabet, a single digit or a single special symbol.
EX:'N'
'S'
'Navtutorials'
Keywords
Keywords cannot be used as variables.
auto | double | int | struct | break | else | long |
switch | case | enum | register | typedef | extern | retern |
union | const | float | sizeof | unsigned | continue | for |
goto | signed | volatile | do | if | static | while |
Identifiers
- first character must be an alphabet or underscore.
- Must consist of only letters, digits or underscores.
- Cannot be used a keyword.
- Must not contain white space
Variables
- A variable is a data name that may be used to store a data value.
- Variables may take different values at different times during execution.
EX: counter
avg
total
Invalid: 985
*