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:

  1. It contains at least one digit.
  2. Fractions or decimals are not allowed.
  3. By default an integer constant is considered to be positive.
  4. Blank spaces and commas are not allowed.
  5. 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:

  1. They are also known as  floating point constants. Fractional and exponential form are the parts of the real constants.
  2. It needs to have at least one digit.
  3. Decimal point needs to be there.
  4. It can be positive or negative but by default real constants are positive.
  5. 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.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay

Looking for a Fresher Job? Post Your Resume Free !!!

More Articles From "C Programming" Category

home | top

TopOfBlogs