Variables in C language are names that represent memory locations used to store and change data values during program execution. Variables must be named in a clear way and can consist of letters, digits, and underscores. They must begin with a letter and have a maximum length of 31 characters. Examples of valid variable names include "John" and "T_raise" while invalid names include "123" or names with spaces.
1 of 7
More Related Content
Variables in C
1. Variables in C Language
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 1
2. Variable
A data name that may be used to store a data value.
Uses the primary storage area.
Value vary during the execution time.
May take different values at different times.
Basically memory locations which are given names and
referred in the program by variable names.
Are used for identification for entering the information and
data.
Must be in a meaningful way to reflect its function and
nature in the program.
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 2
5. Rules for
defining a
variable
Must begin with a letter
Some systems permit underscore as a first character.
Length can be maximum up to 31 characters.
Uppercase and lowercase letters are significant.
White space is not allowed.
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 5
6. Examples of
valid and
invalid variable
names:
John
mark
x1
T_raise
ph_value
Valid
123
%
(area)
25th
Invalid
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 6