Different types of constants available in C Programming
Constant in C Programming are classified into four categories namely Integer Constant, real constant, character constant and string constants.
1. Integer Constant:
Integer constant reference to the sequence of the digit. It must not have any character except digit, however, an Integer Constant may be preceded by
‘+’ or ’-’.
153, -876, 3543, 0, 2, -998, +118 are the valid integer constant.
11,435, $ 4000, Rs 5000, 7500 /- are invalid constant.
2. Real Constant:
A real constant in the C is numeric constant with a sign of decimal point or exponent or a combination. Following is an example showing the list of invalid and valid real constant.
34.789.0.0001.9.0, 3e-9, +247.0,4e-3,2.58e+3, 315 are the valid real constant.
2,2,000. 00,.34e+12.67 are invalid real constants.
3. Character Constant :
A character constant is any symbol or value that is the part of valid character set. A valid character constant must be enclosed within the single quotes.
Char c ; /* define the character c */
c = ‘B’ ; /* assigns character ‘B’ to the variable c of character type. */
4. String Constant:
A string constant is the sequence of the one or more characters from the defined character set i.e. Following are the example of valid string constants.
"Fine”, “227863”, “@#$%&*”, “b” are the valid string constants.
Read this: to know what is token in c programming!
Hope you like this articles! if you really like this article so don’t forget to give us a small feedback or review
The post Different types of Constants available in C Programming appeared first on All In One Tuts.
This post first appeared on All In One Tuts | Tech Tutorials And Videos | Tech, please read the originial post: here