C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds


Posted By: Morgan Brown     Category: C Programming     Views: 12574

This article explains about constants with example in C programming.

Constants in C

Integer Constants

  • An integer constant refers to a sequence of digits
  • There are three type of integers Decimal, Octal and Hexadecimal
  • Decimal integers consists of set of digits, preceded by optional + or - sign
  • Embedded spaces, commas, and non digit characters are not allowed

Examples of Integer Constants

 Valid Constants

  Invalid Constants 



 15 750


























Examples of Valid Real Constants








3.18E3--Underline word is Exponent 


-1.2e-1 --Underline word is Mantissa 


Embedded space is not allowed 

Examples of Numeric Constants






 Long integer 



 , not allowed



 Unary + allowed 






 White space NA 






 Exp must be int



 $ not allowed



 Hexadecimal int

Single Character Constants

  • A (single) character constant contains a single character within pair of single quotes
  • ‘5’  ‘X’ ‘;’  ‘ ‘     are examples of character constants
  • Note that ‘5’ is different than 5
  • Character constant have integer values, known as ASCII values
  • Printf (“%d”,’a’); and printf(“%c”,97);

String Constants

  • Is a sequence of characters enclosed in double quotes ex. “Hello!” or “1997”
  • ‘x’ is different than “x”!
  • A character string does not have any ASCII value associated with it
  • Few other examples are “Well Done!” “?..!” “5+3” “!@$”

Backslash Character Constants






 Audible alert


 Vertical tab


 Back space


 Single quote


 Form feed


 Double quote


 New line


 Question mark


 Carriage return


 Back slash


 Horizontal tab



Symbolic Constants

  • The scanf() function and &
  • Defining symbolic constants
  • Modifiability and understandability
  • Usually written in capitals
  • # is needed but ; is not allowed in the end
  • Assignment statement is not allowed
  • It can reside anywhere before usage



Didn't find what you were looking for? Find more on Constants Or get search suggestion and latest updates.

Morgan Brown
Morgan Brown author of Constants is from London, United Kingdom.
View All Articles

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!