C – Constants

Home/Learn C Programming/C – Constants
C – Constants 2017-08-05T14:21:40+00:00

Constant :

Constant in C refer to fixed valued that do not change during the execution of a program. const is a keyword and is used to declare constants.

Syntax :

const  datatype  identifier=value;


const datatype identifier-1=value,….,identifier-n=value;

Types of Constants :

Integer constant

Floating-point constant

Character constant

String constant

Integer and floating-point constant represent numbers. They are often referred to as numeric-type constant. The following rule applies to all numeric type constants:

  • Comma and blank spaces cannot be included within the constants.
  • Constant can be preceded by a – or + sign, if desired. If either sign does not precede the constant it is assumed to be positive.
  • The value of a constant cannot exceed specified minimum and maximum bounds. For each type of constant, these bound vary from one C compiler to another.

Example :

const int a=100;

const int a=10,b=20,c=30;





In the  above program    we give a=200, we will get an error can’t modify a constant object

Prev Next