what is the diff b/w static and non static variables in C.
Give some examples plz.

Answer Posted / anil kumar

Static variables are used for internal contextual
communication purpose.
non static variables are not used for contextual
communication
for that please go through the below code:

static int i=10;
int main()
{
int x=20;
Printf(“%d %d”,x, i);
Fun();
return 0;
}
Void Fun()
{
Printf(“%d”, i);
}

In the above code “i” is the static variable and “x “is the
local variable

Is This Answer Correct ?    22 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can static variables be declared in a header file?

620


Is c easy to learn?

563


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

678


What is the c value paradox and how is it explained?

577


Why do we use return in c?

571






Explain the use of 'auto' keyword

681


What are the types of data files?

731


What does typeof return in c?

640


how do you programme Carrier Sense Multiple Access

1520


How can I find the modification date and time of a file?

606


What is the use of getch ()?

640


why return type of main is not necessary in linux

1708


Write a C Program That Will Count The Number Of Even And Odd Integers In A Set using while loop

1719


What are types of structure?

608


Why is #define used?

792