際際滷

際際滷Share a Scribd company logo
Variables in C Language
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 1
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
Variable may
consist of
Letters
Digits
Underscore(_)
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 3
Examples of
Variable
Average
height
Total
Counter_1
Class_strength
distance
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 4
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
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
ThankYou
By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 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
  • 3. Variable may consist of Letters Digits Underscore(_) By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 3
  • 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
  • 7. ThankYou By: Satveer Kaur, Assistant Professor, Khalsa College, Patiala. 7