C Constants

C Constants refer to fixed values whose values remain the same during the whole program. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal.

Difference between constants and variables

Constants are also like normal variables. But, the only difference is, Constants values can’t be modified by the program once they are defined. While we can change the value of variables.

Types of C Constants:

Here is the list of all types of Constants supported in C language.

ConstantType of Value Stored
Integer ConstantIt stores integer value
Floating ConstantIt stores float value
Character ConstantIt stores character value
String ConstantIt stores string value

Declaration of Constant in C:

Here is the list which will help you to understand how to declare constants:

const int a = 10;read as “a is an integer which is constant”
int const a = 10;read as “a is a constant integer”

Example of C Constant:

Let’s see an Example of C program:

int main()
  int const x=10;
  float const y=20.50;
  char const c='w';

  x=20; // not allowed
  y=10.40; // not allowed
  c='v'; // not allowed
return 0;

Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.