Variable:
Variable is an entity whose value can vary (i.e. change) during execution of a program.
int a = 20;

- #include<stdio.h>
- main()
- {
- printf("********* Example Variable *********\n");
- int i, j;
- i = 10; j = 20;
- printf("\n value of i=%d & j=%d \n",i, j);
- // change the value of variable
- printf("\n change value of variable ");
- i = 50;
- printf("\n After changing value of variable i is : %d \t", i);
- getch();
- }

Real life example of variable
- Everyone has a saving / current bank account. From this account you can withdraw money from ATM or deposit money by visiting the bank.


Constant:
Constant is an entity whose value cannot be changed throughout the execution of program.
const int j = 50;
- #include<stdio.h>
- main()
- {
- printf("********* Example Constant *********\n");
- const int i = 100;
- printf("\n value of constant i= %d \n",i);
- i = 50;
- printf("\n%d \t", i);
- getch();
- }
- #include<stdio.h>
- main()
- {
- printf("********* Example Constant *********\n");
- const int i ;
- printf("\n value of constant i= %d \n",i);
- //i = 50;
- printf("\n%d \t", i);
- getch();
- }

Real life example of constant
- Now suppose we want to create a fixed deposit in bank. This is done to keep a particular amount locked for some specific period.

Summary:
This article will help fresher candidates to understand Variables & Constants in C with Real Life Example.

Rupesh KahanePosted Dec 30, 2015, 12:24 PM
thanks Harshad Pansuriya
Harshad PansuriyaPosted Nov 13, 2015, 11:00 PM
Nice one
Rupesh KahanePosted Nov 13, 2015, 9:51 PM
thanks to Santhakumar Munuswamy & Banketeshvar Narayan also
Banketeshvar NarayanPosted Nov 13, 2015, 4:49 PM
Nice Article
Santhakumar MunuswamyPosted Nov 13, 2015, 10:11 AM
Good one
Rupesh KahanePosted Nov 13, 2015, 8:56 AM
Thanks Debasis Saha
Debasis SahaPosted Nov 13, 2015, 8:44 AM
Good Share
Rupesh KahanePosted Nov 12, 2015, 11:56 PM
thanks to all Sibeesh Venu, Raja T & Anish Ansari
Anish AnsariPosted Nov 12, 2015, 8:37 AM
NIce
Raja TPosted Nov 12, 2015, 4:16 AM
Good one, Thanks for sharing ..
Sibeesh VenuPosted Nov 12, 2015, 4:03 AM
Nice Share