Social Icons

9 July 2012

0 What is a variable in C?

A variable is an identifier that is used to represent some specified type of information within a designed portion of the program.In its simplest form  a variable is an identifier that is used to represent a single data item; i.e., a numerical quantity or a character constant . The data item may be assigned to the variable at some point of time in the program. Then data item can be accessed later in the program simply by referring to the variable name.Variable names are names given to locations in memory. These locations can contain integer, real or character constants.

  A given variable can be assigned different data items at various places within the program. Thus , the information represented by the variable can change during the execution of the program. However, the data type associated with the variable can not be changed.

Syntax for declaring a variable of a given type-
    type identifier ;

Here type represent the data type and identifier represents the variable name.

for example, 
              int a; 
              float num; 
             char ch;

Here a, num and ch are the identifiers of type int, float and char respectively.

These variable can be assigned values at the time of their declaration or at any point in the program wherever and whenever needed.
For example,
                  int a=5;

0 comments:

Post a Comment

Hey this is a test comment

Related Posts Plugin for WordPress, Blogger...