C Programming Primary Constants: Integer, Real & Character
Posted on January 25, 2010
Integer, Real & Character: C Primary Constants
In the last article we gave an introduction about the kinds of Constants in C Language.
In this article we will discuss only about primary constants and secondary constants will be discussed in the later articles.
1) Integer Constants:
- It contains at least one digit.
- Fractions or decimals are not allowed.
- By default an integer constant is considered to be positive.
- Blank spaces and commas are not allowed.
- The range of all the integer constants has been discussed earlier.
For example :
const int age=20;
and
int const age=20;
Above example tells us about the declaration of an integer constants and we can use any of the form as shown above.
2) Real Constants:
- They are also known as floating point constants. Fractional and exponential form are the parts of the real constants.
- It needs to have at least one digit.
- Decimal point needs to be there.
- It can be positive or negative but by default real constants are positive.
- It is similar to integer constants but the difference is that decimal point is required in integer constants.
3) Character Constants:
Characters enclosed in single quotes are known as character constants and characters enclosed within double quotes are known as string constants. There are certain characters which cannot be represented in this manner therefore we follow a different character sequence i.e.
We use:
- ‘\n’ for new line.
- ‘\t’ for space.
- ‘\0’ for null elements etc.
This is all about the primary constants. We will be discussing secondary constants in the next tutorial.
Looking for a Fresher Job? Post Your Resume Free !!!
More Articles From "C Programming" Category
- Variable Types in C Programming Language
- Derived Data Types in C Programming Language
- C Language Operator Types: Operators in C
- Constants in C Programming Language: Primary & Secondary
- Storage Classes in C Programming Language: Auto, Register, Extern & Static Storage Types
- C Data Types: Range & Size
- Type Modifiers in C Language: signed, unsigned, long & short
- C Language Fundamental Data Types: Int, Float, Char, Double
- C Language Data Types
- C Language Keywords