CoolInterview.com - World's Largest Collection of Interview Questions
 Interview Questions  
 Our Services  

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!


    Send your Resume to 6000 Companies


  • INTERVIEW QUESTIONS LANGUAGES C DETAILS
    Question :
    What is a static function?



    Category C Interview Questions
    Rating (0.0) By 0 users
    Added on 7/19/2006
    Views 2365
    Rate it!
    Answers:

    Also if a variable is declared to be static, then its value doesn't change within that function.



    Static Function is a function which is only used in the file where it is declared and defined. Other files cannot use that particular function.

    /*************************************
    *
    * Function declarations (prototypes).
    *
    *************************************/

    /* Func1 is only visable to functions in this file. */

    static void Func1(void);

    /* Func2 is visable to all functions. */

    void Func2(void);

    /*************************************
    *
    * Function definitions
    *
    *************************************/

    void Func1(void)
    {
    puts("Func1 called");
    }

    /*************************************/

    void Func2(void)
    {
    puts("Func2 called");
    }



     Posted by: Syed Baseer Ahmed    

    Contact Syed Baseer Ahmed  Contact Syed Baseer Ahmed

    static is a one of data storage class .whenever we declared the variable as static the value of variable is not changed.
    i.e the scope of varible is entire program
    ex:
    int static a ;
    {
    a=1
    while(a>0)
    {
    a=a+2;
    }
    printf("%d",a);
    }
    in the above program the value of "a" is each time incremented by 2.it does not reintialise to 1 each time



     Posted by: sreelatha    

    Contact sreelatha  Contact sreelatha

    static functions cannot be called using objects.
    static functions can have the static variables.
    Eg:
    public static void main(String args[])
    in java.



     Posted by: nithya    

    Contact nithya  Contact nithya

    WE can call a function in many ways
    1)we can call it using fname
    2)in c++ we can call it using object also
    3)using friend functions we call them normally
    4)in java there is another advantage in calling a function i.e
    using STATIC keyword
    for example:
    class demo
    {
    void A()
    {
    Syste.out.println("kishore");
    }
    static void B
    {
    Syste.out.println("reddy");
    }
    public static void main(String a[])
    {
    demo d;
    d.A();
    B();
    }
    }

    So here the function with static keyword is called directly with out using object and '.' operator.



     Posted by: kishore reddy    

    Contact kishore reddy  Contact kishore reddy

    static function is used access the static member variables.



     Posted by: chandu    

    Contact chandu  Contact chandu


    If you have the better answer, then send it to us. We will display your answer after the approval.
    Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

       
    Related Questions
    View Answer
    How do you print an address?


    View Answer
    What is the difference between NULL and NUL?


    View Answer
    What is the stack?


    View Answer
    What is a null pointer?


    View Answer
    How can I convert a number to a string?


    View Answer
    What is the difference between #include <file> and #include ?file??


    View Answer
    What is Preprocessor?


    View Answer
    What is the difference between text and binary modes?


    View Answer
    What is the benefit of using const for declaring constants?


    View Answer
    What is the difference between declaring a variable and defining a variable?


    View Answer

    Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

    Notify me when better answer is posted!
    Email:

    View ALL C Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2009 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions
    Page URL: http://www.coolinterview.com/interview/6068/default.asp?cachecommand=bypass


    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | Joke of the Day

    0.45