in Technology by
What is a static variable in C-Programming?

1 Answer

0 votes
by

A static local variables retains its value between the function call and the default value is 0. The following function will print 1 2 3 if called thrice.

void f() { 

   static int i; 

   ++i; 

   printf(“%d “,i); 

}

If a global variable is static then its visibility is limited to the same source code.

Related questions

+1 vote
    What is a static function in C Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
+1 vote
    Which operator can be used to access union elements if union variable is a pointer variable in C Programming ?...
asked Nov 9, 2020 in Technology by JackTerrance
+1 vote
    Which operator can be used to determine the size of a data type or variable in C Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
+1 vote
    What is a variable in C programming?...
asked Nov 9, 2020 in Technology by JackTerrance
+1 vote
    Which operator is used to receive the variable number of arguments for a function in C Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
+1 vote
    What is the difference between variable declaration and variable definition in C-Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
+1 vote
    Where an automatic variable is stored in C-Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
0 votes
    I have some ASP.NET web services which all share a common helper class they only need to instantiate one ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 31, 2022 in Education by JackTerrance
0 votes
    I have some ASP.NET web services which all share a common helper class they only need to instantiate one ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 30, 2022 in Education by JackTerrance
0 votes
    I have some ASP.NET web services which all share a common helper class they only need to instantiate one ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 29, 2022 in Education by JackTerrance
0 votes
    I have some ASP.NET web services which all share a common helper class they only need to instantiate one ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 29, 2022 in Education by JackTerrance
0 votes
    I'm having some trouble recently. On a WebForm I declare a static object, like this : public static ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    I'm having some trouble recently. On a WebForm I declare a static object, like this : public static ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    I'm having some trouble recently. On a WebForm I declare a static object, like this : public static ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
...