As the name suggests the name constants is given to such variables or values in C programming language which cannot be modified once they are defined. They are fixed values in a program. There can be any types of constants like integer, float, octal, hexadecimal, character constants etc. Every constant has some range. The integers that are too big to fit into an int will be taken as a long. Now there are various ranges that differ from unsigned to signed bits. Under the signed bit, the range of an int varies from -128 to +127 and under the unsigned bit, int varies from 0 to 255.
Integer Constant: 10 Floating point Constant: 4.500000 Character Constant: G
A variable in simple terms is a storage place which has some memory allocated to it. Basically, a variable used to store some form of data. Different types of variables require different amounts of memory and have some specific set of operations which can be applied to them.
A typical variable declaration is of the form:
type variable_name; or for multiple variables: type variable1_name, variable2_name, variable3_name;
A variable name can consist of alphabets (both upper and lower case), numbers and the underscore ‘_’ character. However, the name must not start with a number.
Difference between variable and constant
|A value that can not be altered throughout the program||A storage location paired with an associated symbolic name which has a value|
|It is similar to a variable but it cannot be modified by the program once defined||A storage area holds data|
|Can not be changed||Can be changed according to the need of the programmer|
|Value is fixed||Value is varying|
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference between Static variables and Register variables in C
- Difference Between Machine Language and Assembly Language
- Difference Between Assembly Language And Machine Language
- Difference Between C Language and LISP Language
- Difference between Hardware Description Language and Software Language
- Initialization of global and static variables in C
- Variables and Keywords in C
- Static Variables in C
- C Program to print environment variables
- Difference between static and non-static variables in Java
- Difference between Identifiers and Variables in C
- C Programming Language Standard
- C Language Introduction
- Arrays in C Language | Set 2 (Properties)
- Difference between %d and %i format specifier in C language
- Language Processors: Assembler, Compiler and Interpreter
- Difference between while(1) and while(0) in C language
- Difference between Java and C language
- Similarities and Differences between Ruby and C language
- What is the difference between a language construct and a “built-in” function in PHP ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.