C – Automatic

C – Automatic 2017-08-06T10:42:24+00:00

Automatic storage class :

Automatic variables are allocated space in the variable on the stack. To declare a variable in automatic storage class auto specified.

eg:    auto int n;

When you declare a variable, if the omitted variable storage class is automatic.
eg:    int n;

When you declare an automatic variable initialization to be made explicit initial value is undefined.

The scope of an automatic variable is only for the block, or any block within the block, in which it appears. All variables declared within a function are auto by default. A variable can be defined as automatic by placing the keyword auto at the beginning of the variable declaration.

Example:   auto int a;


Output :

a = 10

a = 20

a = 10

a = 30

a = 10

Prev Next