variables and constants in c language
Home » Courses » Variables and Constants In C Language

Variables and Constants In C Language

Variables and Constants In C Language


variables are memory location in computer to store data. To indicate memory location each variable should be great unique variable name.Examples of variable are sum, count etc.

like :  int num;


Rules for variable name in C:-

Rules for variable is also same as Identifier rules.

1:- An identifier can composed letters of uppercase and lowercase and only underscore ‘_’.

2:- First letter of identifier name should be either than of underscore.

3:- There is no rule for the length of an identifier. However, the first 31 characters of an identifier are discriminated by the compiler.



Constants are those values which cannot be change during the time of execution of program.For example : 1, 3.5, “Programming is interesting”,

etc. C constants can be classified as.


Integer Constants:-

Integers constants are numeric constants without any fractional part or exponential part.

Three type of digits decimal , octal and hexa.

Decimal digits: 0,1,2….9

Octal digits:   0,1,2…..7

Hexa digits:    0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F


Floating point constant:-

Float point values are real values. For example , 2.0, 0.0025, -3.5 etc.


Escape Sequence:-

Escape sequence include new lines . For example \n is used  for new lines. The blackslash (\) causes escape from normal way

the compiler interpreted the compiler.


Different Escape sequence are follows:-

\b    It is used for Backspace.

\f    It is used for form feed.

\n    It is used for new line.

\t    It is used for Horizontal tab.

\r    It is used for Return.

\v    It is used for vertical tab.

\\    It is used for Backslash.

\0    It is used for null character and etc.


String constant:-

String constant are those constants which are enclosed in double-quote marks. For example:

“nice”     it is string constant.

“”           it is null string constant.

“He is well\n”    it prints string with newline.


Previous : Introduction to C Language

NextData Types In C Language


A Freelancer web developer, graphic designer and own this blog to spread knowledge.My hobby is computer problem's solving and i love to help other in this field.

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.