SlideShare a Scribd company logo
Notes on
Storage Classes
Instructor:
Arghodeep Paul
Firmware Engineer at BitBible Technologies Pvt. Ltd.
Content Author: Arghodeep Paul
License: OpenSource
Date: 14 July 2021
Storage Class
Storage class defines the Scope/Visibility and Lifetime of a Variable or Function.
Types
auto: The default class(int a=2 is equal as auto int a=2)
static: Instructs the compiler to keep a local variable in alive during the
runtime/lifetime of a program. By default a variable is created when control comes
into scope of a function and destroyed when going out of scope.
example
#include <stdio.h>
int main() {
void fx(){
static int n=2;
printf("Value: %dn",n);
n++;
}
fx();
fx(); // calling twice
return 0;
}
Extern: This class gives the reference of a global variable of function that defined
into another source file.
Program 1
#include <stdio.h>
extern float banglaMarks;
extern char name[30];
extern void showDetail(void);
main() {
banglaMarks=55;
showDetail();
}
Program 2
#include <stdio.h>
float banglaMarks=99.99;
char name[30]="Humayun Faridi";
void showDetail(void); // declaration
void showDetail(void){ //defination
printf("%s got %0.2f in Bangla Paper",name,banglaMarks);
}
Compile: gcc file1.c file2.c -o Main.exe
register: This will define variable that should be stored in a register instead of RAM.
You can not use & operator with this types of variables as it will not return you RAM
Address(it is stored in CPU that’s why).
Example
#include <stdio.h>
int main() {
register int a;
scanf("%d",&a);
printf("%d",a);
return 0;
}
Scope of a Function
void function(){
//This area is considered as the Scope of this function
}
C storage classes

More Related Content

PPTX
Storage classes in c++
PPT
Storage classes
PPTX
Storage classes in c language
PPTX
Abstract class in c++
PPTX
Storage Class in C Progrmming
PPTX
Storage classes
DOC
What is storage class
PPT
Functions in c
Storage classes in c++
Storage classes
Storage classes in c language
Abstract class in c++
Storage Class in C Progrmming
Storage classes
What is storage class
Functions in c

What's hot (19)

PDF
Pengenalan Unit Testing dan TDD
PPT
Storage classes
DOCX
Basic structure of c programming
PPTX
Recursive Function
PPTX
In search of JavaScript code quality: unit testing
DOCX
Storage class
DOC
Storage classess of C progamming
PPTX
C# Delegates
PPT
The Prana IoC Container
PPT
Oop lec 1
PPT
Java adapter
PPTX
Java Notes
PPTX
Java interface
PDF
overview of c#
PDF
Learn Java Part 2
PPTX
Function in C program
PPTX
Delegates and events in C#
PPTX
Interfaces c#
Pengenalan Unit Testing dan TDD
Storage classes
Basic structure of c programming
Recursive Function
In search of JavaScript code quality: unit testing
Storage class
Storage classess of C progamming
C# Delegates
The Prana IoC Container
Oop lec 1
Java adapter
Java Notes
Java interface
overview of c#
Learn Java Part 2
Function in C program
Delegates and events in C#
Interfaces c#
Ad

Similar to C storage classes (20)

PPT
Lecture 13 - Storage Classes
PPTX
Storage classes
PPTX
Storage classes in C
PPTX
Storage_classes_and_Scope_rules.pptx
PPTX
C++ Constructs.pptx
PDF
EXTERN -- wherever u define variables, it will get access to use them
PDF
Advanced C Programming Notes
PPTX
Storage classes in C
PDF
Data structure scope of variables
PDF
Latest C Interview Questions and Answers
PPTX
Storage Class Specifiers in C++
PPTX
11 lec 11 storage class
PPSX
Object oriented concepts & programming (2620003)
PDF
Unit 5 quesn b ans5
PPTX
Storage class in C Language
PDF
Data structure week 1
PDF
C++ Object oriented concepts & programming
PPTX
Operator Overloading and Scope of Variable
PDF
Preprocessor directives
Lecture 13 - Storage Classes
Storage classes
Storage classes in C
Storage_classes_and_Scope_rules.pptx
C++ Constructs.pptx
EXTERN -- wherever u define variables, it will get access to use them
Advanced C Programming Notes
Storage classes in C
Data structure scope of variables
Latest C Interview Questions and Answers
Storage Class Specifiers in C++
11 lec 11 storage class
Object oriented concepts & programming (2620003)
Unit 5 quesn b ans5
Storage class in C Language
Data structure week 1
C++ Object oriented concepts & programming
Operator Overloading and Scope of Variable
Preprocessor directives
Ad

More from ArghodeepPaul (12)

PDF
Microprocessor questions converted
PDF
Windows script host
PDF
Windows batch scripting
PDF
Common problems solving using c
PDF
C operators
PDF
C taking user input
PDF
C datatypes
PDF
C variables and constants
PDF
C program structure
PDF
Computer programming tools and building process
PDF
Algorithm pseudocode flowchart program notes
PDF
notes on Programming fundamentals
Microprocessor questions converted
Windows script host
Windows batch scripting
Common problems solving using c
C operators
C taking user input
C datatypes
C variables and constants
C program structure
Computer programming tools and building process
Algorithm pseudocode flowchart program notes
notes on Programming fundamentals

Recently uploaded (20)

PPTX
Module 8- Technological and Communication Skills.pptx
PPTX
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
PDF
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
737-MAX_SRG.pdf student reference guides
PDF
August 2025 - Top 10 Read Articles in Network Security & Its Applications
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PPTX
Fundamentals of Mechanical Engineering.pptx
PPTX
Feature types and data preprocessing steps
PPTX
Software Engineering and software moduleing
PDF
Soil Improvement Techniques Note - Rabbi
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPTX
communication and presentation skills 01
PPT
Total quality management ppt for engineering students
PPTX
introduction to high performance computing
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PDF
Improvement effect of pyrolyzed agro-food biochar on the properties of.pdf
PDF
August -2025_Top10 Read_Articles_ijait.pdf
PPTX
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
Module 8- Technological and Communication Skills.pptx
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
737-MAX_SRG.pdf student reference guides
August 2025 - Top 10 Read Articles in Network Security & Its Applications
Exploratory_Data_Analysis_Fundamentals.pdf
Fundamentals of Mechanical Engineering.pptx
Feature types and data preprocessing steps
Software Engineering and software moduleing
Soil Improvement Techniques Note - Rabbi
III.4.1.2_The_Space_Environment.p pdffdf
communication and presentation skills 01
Total quality management ppt for engineering students
introduction to high performance computing
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
Improvement effect of pyrolyzed agro-food biochar on the properties of.pdf
August -2025_Top10 Read_Articles_ijait.pdf
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx

C storage classes

  • 1. Notes on Storage Classes Instructor: Arghodeep Paul Firmware Engineer at BitBible Technologies Pvt. Ltd. Content Author: Arghodeep Paul License: OpenSource Date: 14 July 2021
  • 2. Storage Class Storage class defines the Scope/Visibility and Lifetime of a Variable or Function. Types auto: The default class(int a=2 is equal as auto int a=2) static: Instructs the compiler to keep a local variable in alive during the runtime/lifetime of a program. By default a variable is created when control comes into scope of a function and destroyed when going out of scope. example #include <stdio.h> int main() { void fx(){ static int n=2; printf("Value: %dn",n); n++; } fx(); fx(); // calling twice return 0; } Extern: This class gives the reference of a global variable of function that defined into another source file. Program 1 #include <stdio.h> extern float banglaMarks; extern char name[30]; extern void showDetail(void); main() { banglaMarks=55; showDetail(); }
  • 3. Program 2 #include <stdio.h> float banglaMarks=99.99; char name[30]="Humayun Faridi"; void showDetail(void); // declaration void showDetail(void){ //defination printf("%s got %0.2f in Bangla Paper",name,banglaMarks); } Compile: gcc file1.c file2.c -o Main.exe register: This will define variable that should be stored in a register instead of RAM. You can not use & operator with this types of variables as it will not return you RAM Address(it is stored in CPU that’s why). Example #include <stdio.h> int main() { register int a; scanf("%d",&a); printf("%d",a); return 0; } Scope of a Function void function(){ //This area is considered as the Scope of this function }