Auto Example:
#include<stdio.h> void main() { Display(); Display(); Display(); } void Display(){ auto int x=1; x=x+5; printf("%d\n",x); }
Output:
6
6
6
Static Example:
#include<stdio.h> void main() { Display(); Display(); Display(); } void Display(){ static int x=1; x=x+5; printf("%d\n",x); }
Output:
6
11
16
Register:
#include<stdio.h> int main(){ register int a,b,c; a=10; b=20; c=a+b; printf("%d",c); return 0; }
It will take short time as calculation happen in registers.
extern example:
#include<stdio.h> void test(){ extern int gvar; printf("gvar=%d",gvar); gvar=20; } int gvar; int main(){ //extern int gvar; printf("gvar=%d\n",gvar); gvar=10; test(); printf("gvar = %d",gvar); return 0; }