Static Storage Class Assignment Help

Assignment Help: >> What is a Storage Class >> Static Storage Class

Static Storage Class

                    The scope of static variables can be local or global. It depends whether static declaration statement is given outside all functions (including main ( ) function),or inside a particular module. The characteristics are:

1.      Their scope may be local or global.

2.      Lifetime of static variables (either it is static local or static global) is equal to lifetime or program, the reason will be just apparent to you after the following discussion.

3.      Static variables have a special feature that they retain their value during the execution of the program (even during the multiple calls to a function this property is most useful in solving recursive problems.

4.      The storage to static variables is allocated in RAM.

5.      The default value of static variables is garbage.

The following program will explain the use of static variables:

 EXAMPLE:-

                    #include<stdio.h>

                    #include<conio.h>

                    Void example ( );

                    Void main ( );

                    {       Int I ;

                             Clarscr ( ) ;

                             For (i= 0 ; I <= 3 ; I ++)

                            {     example ( ) ;            }

                             Getch ( ) ;

                    }

                    Void example ( )

                    {

                            Static int x= 10;                                          //local static variable

                             X=x +10;                                    //local static variable

                             Printf ("%d\t", x);

                    }

                    The output of this program will be

                    20         30       40

Try the same program with variable x declared as auto or register variable. The output will be :

                    20        20        20

                    That clearly means that static variable x retains its value (i.e.. remains active) even when the function example ( ) is exited. In contrast the automatic and register variables loss their value after every exit from the function. It also means that the initialization statement at the start of function example ( ) (i.e. static x = 10) executes only the first time function example ( ) is entered afterwards that statement will not execute. In other words variables are initialized only once during compile-time.

                   Note that local static variables are similar to automatic variables except that they retain their value permanently for the entire duration of program execution.

 

Data Structure & Algorithms Assignment Help, Live Experts 

Struggling with data structure problems? Data structure subject is quite tough to learn? Need quick assistance in data structure questions? ExpertsMind.com is right place for you where your search ends, We at ExpertsMind offer online data structure assignment help, data structure homework help and data structure and algorithms question's answers by best online support by qualified tutors.


ExpertsMind.com - Static Storage Class Assignment Help, Static Storage Class Homework Help, Static Storage Class Assignment Tutors, Static Storage Class Solutions, Static Storage Class Answers, What is a Storage Class Assignment Tutors

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd