DECLARATION OF STORAGE CLASS
Variables in C can have not only data type but also storage class that provides information about their location and visibility. The storage class decides the portion of the program within which the variables are recognized. Consider the following example:
/* Example of storage classes */
int m;
main()
{
int i;
float balance;
.....
.....
functions1();
}
function1()
{
int i;
float sum;
.....
.....
}
The variable m which has been declared before the main is called a global variable. It can be used in all the functions in the program. It need not be declared in the functions. A global variable is also known as an external variable.
C Numbers Pattern Programs With Easy Solutions
C Star Pattern Programs With Easy Solutions
C Numbers Pattern Programs With Easy Solutions
C Star Pattern Programs With Easy Solutions
The variables i, balance and sum are called local variables because they are declared insides a function. Local variables are visible and meaningful only inside the functions in which they are declared.
They are not known to other functions. Note that the variable i has been declared in both the functions. Any change in the value of i in one function does not affect its value in the other.
C provides a variety of storage class specifiers that can be used to declare explicitly the scope and lifetime of variables. The concepts of scope and lifetime are important only in multifunction and multiple file programs and therefore the storage classes are considered in detail later when functions are discussed. For now, remember that there are storage class specifiers (auto, register, static and extern) whose meanings are given in Table 2.10.
The storage class is another qualifier (like long or unsigned) that can be added to a variable declaration as shown below:
auto int count;
register char ch;
static int x;
extern long total ;
Static and external (extern) variables are automatically initialized to zero. Automatic (auto) variables contain undefined values (known as 'garbage') unless they are initialized explicitly.
Apply Indian Army – 10+2 TECHNICAL ENTRY SCHEME – 44 COURSE
ReplyDeleteClick Here
How to Download Neet 2020 Exam Admit Card
ReplyDeleteDownload
IBPS Clerk Recruitment 2020 (1557) Post
ReplyDeleteApply Online
Download Free Latest Version of Windows 10 2020
ReplyDeleteDownload Windows 10 2020
Top 5 New Technology Trends for 2021
ReplyDeleteGet Info
software developer jobs for freshers
ReplyDeleteClick Here
Campus drive by Gridlogics Technologies | Software Engineering Jobs
ReplyDeletehttps://bit.ly/3xi4rdb
Campus drive by Gridlogics Technologies | Software Engineering Jobs
ReplyDeleteClick Here
Download Free Windows 7 All Versions 32/64 Bit ISO July-2021
ReplyDeleteDownload
Mahavitaran (MSEB) Recruitment 2021 | Government Job
ReplyDeleteApply Now
Download Free Windows 7 Ultimate 32/64 Bit ISO May-2022
ReplyDeleteDownload Now
Download Free IGI 3: The Plan | PC Game
ReplyDeleteDownload IGI 3