It is a symbolic name assigned to a data item by the programmer. At any particular time, it will stand for one particular data, which may change from time to time during a computing process. code example

Example 1: Write a C program to do the following: (10 marks) a. Declare two variables a and b of type integer b. Initialise the value of variable a to 3 and the value of variable b to 0 c. If the value of a is greater than 0, then assign b the value of a + 3

/*
 * Comment to state the purpose of this program (filename.c)
 */
#include 
 
int main() {
  int a=3,b=0;
  if(a>b){
  b=a+3;
  printf("%d",b);
  }
 
   return 0;
}

Example 2: in coding why one variable define another

% In Matlab, Arrays start at index 1               % In Matlab, Arrays are indexed using parentheses ()               % Thus in Matlab:                              quiz_grades(1) = 98;               average_quiz_score =  ( quiz_grade(1) + quiz_grade(2) +  quiz_grade(3) ) / 3.0;

Tags:

Misc Example