Monday, May 27, 2019

Storage Classes In C

Storage Classes In C Are Used To Define Scope And Lifetime Of Our Variable.

Storage Class Storage Place Default Value Scope Lifetime
Auto RAM Garbage Value Local Within The Function
Static RAM Zero Local Till The End Of Main Program, Retains The Value Between Multiple Function Calls.
Register Register Garbage Value Local Within The Function

 

Register Variable

The Register Variable Allocates Memory In The Register Than RAM Its Size Of Register Size.

It Has Faster Access Than Other Variables.

 

Note

We Cant Get The Address Of Register Variable

 

Example

#include<stdio.h>

#include<conio.h>

void main()

{

int n1,n2;

register int sum;

clrscr();

printf(“Enter Any Two Integers”);

scanf(“%d%d”,&n1,&n2);

sum=n1+n2;

printf(“Sum Of %d and %d is %d”,n1,n1,sum);

getch();

}

 

Result

Enter Two Integers 1 2

Sum Of 1 and 2 Is 3

 

 

One thought on “Storage Classes In C

Leave a Reply