

- 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 a register storage class in C language?
There are four storage classes in C programming language, which are as follows −
- auto
- extern
- static
- register
Register variables
The keyword is register.
Register variable values are stored in CPU registers, rather than in memory where, normal variables are stored.
Registers are temporary storage units in CPU.
They allow faster access time for register variables than normal variables.
Example 1
Following is the C program for register storage class −
#include<stdio.h> main ( ){ register int i; for (i=1; i<=5; i++) printf ("%d ",i); }
Output
The output is stated below −
1 2 3 4 5
Example 2
Consider another C program for register storage class −
#include<stdio.h> int main(){ register int a; printf("%d",a); //prints default value of a =0 }
Output
The output is stated below −
0
Example 3
Following is the third C program for static storage class −
#include<stdio.h> int main(){ register int i = 10; int *p; //int *p = &i; //error occurred ,here we are trying to request address of register variable printf("Value of i: %d", *p); printf("Address of i: %u", p); }
Output
The output is stated below −
Error:add of reg var?
- Related Questions & Answers
- What is a static storage class in C language?
- The register storage class in C++
- What is an auto storage class in C language?
- What is an extern storage class in C language?
- Different storage classes in C Language
- What is Register Renaming?
- What is Shift Register?
- What is Register Transfer?
- The auto storage class in C++
- The static storage class in C++
- The extern storage class in C++
- The mutable storage class in C++
- What is General Register Organization?
- What is Storage Management?
- What is a malloc function in C language?
Advertisements