# Types of C Constant

## C constants can be divided into two major categories:

1. Primary Constants:
2. Secondary Constants:

At this stage we would restrict our discussion to only Primary Constants, namely, Integer, Real and Character constants. Let us see the details of each of these constants. For constructing these different types of constants certain rules have been laid down. These rules are as under:

## Rules for Constructing Integer Constants

• An integer constant must have at least one digit.
• It must not have a decimal point.
• It can be either positive or negative.
• If no sign precedes an integer constant it is assumed to be positive.
• No commas or blanks are allowed within an integer constant.
• The allowable range for integer constants is -32768 to 32767.
• Truly speaking the range of an Integer constant depends upon the compiler. For a 16-bit compiler like Turbo C or Turbo C++ the range is –32768 to 32767. For a 32-bit compiler the range would be even greater.

## Rules for Constructing Real Constants

Real constants are often called Floating Point constants.

The real constants could be written in two forms—

• Fractional form
• Exponential form.

Following rules must be observed while constructing real constants expressed in fractional form:

• A real constant must have at least one digit.
• It must have a decimal point.
• It could be either positive or negative.
• Default sign is positive.
• No commas or blanks are allowed within a real constant.

The exponential form of representation of real constants is usually used if the value of the constant is either too small or too large. It however doesn’t restrict us in any way from using exponential form of representation for other real constants.

In exponential form of representation, the real constant is represented in two parts. The part appearing before ‘e’ is called mantissa, whereas the part following ‘e’ is called exponent.

Following rules must be observed while constructing real constants expressed in exponential form:

• The mantissa part and the exponential part should be separated by a letter e.
• The mantissa part may have a positive or negative sign.
• Default sign of mantissa part is positive.
• The exponent must have at least one digit, which must be a positive or negative integer.
• Default sign is positive.
• Range of real constants expressed in exponential form is -3.4e38 to 3.4e38.

## Rules for Constructing Character Constants

• A character constant is a single alphabet, a single digit or a single special symbol enclosed within single inverted commas.
• Both the inverted commas should point to the left.
• For example, ’A’ is a valid character constant whereas ‘A’ is not.
• The maximum length of a character constant can be 1 character.

## Related Posts

• 77
Welcome to the C Knowledge Base and Tutorial   Introduction to C Programming Start Learning C Programming What is C? Why We should learn C C Character Set : Constants, Variables and Keywords Constant and Variable in C: C Keywords: Types of C Constant Rules for Constructing Integer Constants Rules…
Tags: rules, constants, constructing, types, tutorial, constant, integer, character, programming, learning
• 44
The three primary constants and variable types in C are integer, float and character. A variable name can be of maximum 31 characters. Do not use a keyword as a variable name. An expression may contain any sequence of constants, variables and operators. Operators having equal precedence are evaluated using…
Tags: constants, types, integer, primary, learning, character, learn, tutorial
• 42
Before we can begin to write serious programs in C, it would be interesting to find out what really is C, how it came into existence and how does it compare with other computer languages. In this chapter we would briefly outline these issues. We will also learn four important…
Tags: learning, learn, form, programming, start, tutorial
• 37
A character denotes any alphabet, digit or special symbol used to represent information. Here is the list of valid character set (Alphabets, Numbers and Symbols) allowed in C. The alphabets, numbers and special symbols when properly combined form constants, variables and keywords. Let us see what are ‘constants’ and ‘variables’…
Tags: constants, character, constant, tutorial, learn
• 36
In order to effectively develop C programs, it will be necessary to understand the rules that are used for the implicit conversion of floating point and integer values in C. These are mentioned below. Note them carefully. An arithmetic operation between an integer and integer always yields an integer result.…
Tags: integer, real, rules, learn, programming, tutorial

#### Satya Prakash

VOIP Expert: More than 8 years of experience in Asterisk Development and Call Center operation Management. Unique Combination of Skill Set as IT, Analytics and operation management.