Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds

Illustration of static variable

Posted By: Jake Evans     Category: C Programming     Views: 2131

Illustration of static variable.

Code for Illustration of static variable in C Programming

void stat(void);                                                     
   main ( )                                                    
   {                                                           
       int i;                                                  
for(i=1; i<=3; i++)                                     
      stat( );                                            
         }                                                           
   void stat(void)                                                     
   {                                                           
     staticint x = 0;                                      
                                                              
     x = x+1;                                                
     printf("x = %d\n", x);                                  
   } 
                                                          
                                                               Output                                                      
   x = 1                                                       
   x = 2                                                       
   x = 3 
  
Share: 


Didn't find what you were looking for? Find more on Illustration of static variable Or get search suggestion and latest updates.

Jake Evans
Jake Evans author of Illustration of static variable is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!