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 variable in C-Programming?...
asked Nov 9, 2020 in Technology 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 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
0 votes
    Here is the code class method { int counter = 0; public static void main(String[] args) { System.out. ... variables of the class? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Here is the code class method { int counter = 0; public static void main(String[] args) { System.out. ... ),Core Questions, Core Hadoop MCQ,core interview questions for experienced...
asked Oct 31, 2021 in Education by JackTerrance
0 votes
    What is the static variable?...
asked Nov 19, 2020 in Education by Editorial Staff
0 votes
    How to configure static files in Django?...
asked Jul 1, 2021 in Technology by JackTerrance
0 votes
    Static code analysis is performed before the ________ begins. (1)Testing (2)Coding (3)Monitoring (4)Program execution...
asked May 19, 2021 in Technology by JackTerrance
0 votes
    Can “this” be used within a static method?...
asked Mar 31, 2021 in Technology by JackTerrance
0 votes
    How do you differentiate dynamic cache from static cache?...
asked Mar 26, 2021 in Technology by JackTerrance
...