C - Introduction Reusing variables

Introduction

Variables' contents can be changed at any time in the program.

It's possible to reuse variables over and over.

Demo

#include <stdio.h> 

int main() // www  . ja va  2 s.c  o m
{ 
   int prime; 

   prime = 3; 
   printf("i1 is %d\n",prime); 
   prime = 7; 
   printf("i2 is %d\n",prime); 
   prime = 13; 
   printf("i3 is %d\n",prime); 
   return(0); 
}

Result

As you can see, the variable prime is used over and over, each time changing its value.

The new value that's assigned replaces any existing value.

Related Topic