

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is an auto storage class in C language?
There are four storage classes in C programming language, which are as follows −
- auto
- extern
- static
- register
Automatic variables / Local variables
The keyword is auto. These are also called as local variables.
Scope
- Scope of a local variable is available within the block in which they are declared.
- These variables are declared inside a block.
- Default value: Garbage value.
Algorithm
The algorithm is given below −
START Step 1: Declare and initialize auto int i=1 I. Declare and initialized auto int i=2 I. declare and initialized auto int i=3 II. print I value//3 II Print I value //2 Step 2: print I value STOP
Example
Following is the C program for auto storage class −
#include<stdio.h> main ( ){ auto int i=1;{ auto int i=2;{ auto int i=3; printf ("%d",i) } printf("%d", i); } printf("%d", i); }
Output
The output is stated below −
3 2 1
Consider another program for auto storage class.
Example
#include<stdio.h> int mul(int num1, int num2){ auto int result; //declaration of auto variable result = num1*num2; return result; } int main(){ int p,q,r; printf("enter p,q values:"); scanf("%d%d",&p,&q); r = mul(p, q); printf("multiplication is : %d\n", r); return 0; }
Output
The output is stated below −
Run 1: enter p,q values:3 5 multiplication is : 15 Run 2: enter p,q values:6 8 multiplication is : 48
- Related Questions & Answers
- What is an extern storage class in C language?
- The auto storage class in C++
- What is a static storage class in C language?
- What is a register storage class in C language?
- Different storage classes in C Language
- What is an identifier in C language?
- What is an anagram in C language?
- What is an inline function in C language?
- The register storage class in C++
- The static storage class in C++
- The extern storage class in C++
- The mutable storage class in C++
- What is an array class in C#?
- What is an array of structures in C language?
- What is an algorithm and flowchart in C language?
Advertisements