static variable can be initialized only one...
the statement static int var=5 will run only once during the first call of
main  !!


--


Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad




On Mon, Jul 18, 2011 at 11:46 PM, Nishant Mittal <[email protected]
> wrote:

> value of the static variable persists between different function call....
>
>
> On Mon, Jul 18, 2011 at 11:43 PM, geek forgeek <[email protected]>wrote:
>
>>
>>
>> int main()
>> {
>>     static int var = 5;
>>     printf("%d ",var--);
>>     if(var)
>>         main();
>> }
>>
>>
>> y output is 5 4 3 2 1
>>
>> not 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5................................
>>
>> y on each recursive call var is not initialized again.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to