Variables in embedded C programming language

What are variables in the C language? Variables are simple keywords that are defined by the values. Values can be changed. Variables are like a box with some size where values like apples can be put in. So variables can be various forms and sizes, so-called variable types.

Variable type is defined by a reserved word which indicates the type and size of variable identifier:

unsigned char my_char;

long int all_my_numbers;

int number;

Why do we need variables? The basic answer is that memory is limited, and the compiler needs to know much space to reserve for each variable. The coder needs to specify the variable type and its size by using one of the reserved words from the table:

Few statements demonstrating the usage of variables and value assignments:

 {
    int i;      /* Define a global variable i */
    i = 1;      /* Assign i the value 0 */
    {           /* Begin new block of sentences */
      int i;    /* Define a local variable i */
      i = 2;    /* Set its value to 2 */
    }           /* Close block */
    /* Here i is again 1 from the outer block */
  }

Leave a Reply