Thursday 25 April 2019

What is variable in c ?


What is variable in c ?


  • Variables are a way of reserving memory to hold some data.
  • A variable is an identifier for a memory location in which data can be stored and subsequently recalled.
  • Variables are used for holding data values so that they can be utilized in various computations in a program.
  • Every variable is mapped to a unique memory address.
  • Variables are used for holding data values so that they can be utilized in various computations in a program.


All variables have three important attributes.


  • A data type that is established when the variable is defined, e.g., integer, real, character. Once 
  • defined,the type of a C variable cannot be changed.
  • A value that can be changed by assigning a new value to the variable. The kind of values a variable can assume depends on its type. For example, an integer variable can only take integer values, e.g., 2, 100, –12.
  • The number of characters that you can have in a variable name will depend upon your compiler. A minimum of 31
  • characters must be supported by a compiler that conforms to the C language standard.



RULES FOR NAMING C VARIABLE:


  • Variable name must begin with letter or underscore.
  • Variables are case sensitive
  • They can be constructed with digits, letters.
  • No special symbols are allowed other than underscore.
  • sum, height, _value are some examples for variable name


TYPES OF VARIABLES IN C PROGRAM 


  1. Local variable
  2. Global variable
  3. Environment variable

0 comments:

Post a Comment