Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  What is the meaning of using static before fu... Start Learning for Free
What is the meaning of using static before function declaration? For example following function sum is made static
static int sum(int x, int y, int z)
{
    return (x + y + z);
}
  • a)
    Static means nothing, sum() is same without static keyword.
  • b)
    Function need not to be declared before its use
  • c)
    Access to static functions is restricted to the file where they are declared
  • d)
    Static functions are made inline
Correct answer is option 'C'. Can you explain this answer?
Most Upvoted Answer
What is the meaning of using static before function declaration? For e...
Static functions in C have different meanings depending on the context. In this case, when the static keyword is used before a function declaration, it means that the function has internal linkage.

Here's an explanation of each option:

a) Static means nothing, sum() is the same without the static keyword.
This option is incorrect. The static keyword does have a specific meaning when used before a function declaration.

b) Function need not to be declared before its use.
This option is incorrect. The static keyword does not affect the requirement of declaring a function before its use. Regardless of whether a function is declared as static or not, it still needs to be declared before its use.

c) Access to static functions is restricted to the file where they are declared.
This option is correct. When a function is declared as static, its scope is limited to the file where it is declared. This means that the function cannot be accessed from other files using external linkage. It provides encapsulation and helps in preventing naming conflicts with functions in other files.

d) Static functions are made inline.
This option is incorrect. The static keyword does not make a function inline. Inline functions are a separate concept and are declared using the inline keyword.

In summary, the correct answer is option 'C': Access to static functions is restricted to the file where they are declared. Static functions have internal linkage and can only be accessed within the same source file where they are declared.
Free Test
Community Answer
What is the meaning of using static before function declaration? For e...
In C, functions are global by default. Unlike global functions, access to static functions is restricted to the file where they are declared. We can have file level encapsulation using static variables/functions in C because when we make a global variable static, access to the variable becomes limited to the file in which it is declared.
Explore Courses for Computer Science Engineering (CSE) exam

Similar Computer Science Engineering (CSE) Doubts

Top Courses for Computer Science Engineering (CSE)

What is the meaning of using static before function declaration? For example following function sum is made staticstatic int sum(int x, int y, int z){ return (x + y + z);}a)Static means nothing, sum() is same without static keyword.b)Function need not to be declared before its usec)Access to static functions is restricted to the file where they are declaredd)Static functions are made inlineCorrect answer is option 'C'. Can you explain this answer?
Question Description
What is the meaning of using static before function declaration? For example following function sum is made staticstatic int sum(int x, int y, int z){ return (x + y + z);}a)Static means nothing, sum() is same without static keyword.b)Function need not to be declared before its usec)Access to static functions is restricted to the file where they are declaredd)Static functions are made inlineCorrect answer is option 'C'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about What is the meaning of using static before function declaration? For example following function sum is made staticstatic int sum(int x, int y, int z){ return (x + y + z);}a)Static means nothing, sum() is same without static keyword.b)Function need not to be declared before its usec)Access to static functions is restricted to the file where they are declaredd)Static functions are made inlineCorrect answer is option 'C'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for What is the meaning of using static before function declaration? For example following function sum is made staticstatic int sum(int x, int y, int z){ return (x + y + z);}a)Static means nothing, sum() is same without static keyword.b)Function need not to be declared before its usec)Access to static functions is restricted to the file where they are declaredd)Static functions are made inlineCorrect answer is option 'C'. Can you explain this answer?.
Solutions for What is the meaning of using static before function declaration? For example following function sum is made staticstatic int sum(int x, int y, int z){ return (x + y + z);}a)Static means nothing, sum() is same without static keyword.b)Function need not to be declared before its usec)Access to static functions is restricted to the file where they are declaredd)Static functions are made inlineCorrect answer is option 'C'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of What is the meaning of using static before function declaration? For example following function sum is made staticstatic int sum(int x, int y, int z){ return (x + y + z);}a)Static means nothing, sum() is same without static keyword.b)Function need not to be declared before its usec)Access to static functions is restricted to the file where they are declaredd)Static functions are made inlineCorrect answer is option 'C'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of What is the meaning of using static before function declaration? For example following function sum is made staticstatic int sum(int x, int y, int z){ return (x + y + z);}a)Static means nothing, sum() is same without static keyword.b)Function need not to be declared before its usec)Access to static functions is restricted to the file where they are declaredd)Static functions are made inlineCorrect answer is option 'C'. Can you explain this answer?, a detailed solution for What is the meaning of using static before function declaration? For example following function sum is made staticstatic int sum(int x, int y, int z){ return (x + y + z);}a)Static means nothing, sum() is same without static keyword.b)Function need not to be declared before its usec)Access to static functions is restricted to the file where they are declaredd)Static functions are made inlineCorrect answer is option 'C'. Can you explain this answer? has been provided alongside types of What is the meaning of using static before function declaration? For example following function sum is made staticstatic int sum(int x, int y, int z){ return (x + y + z);}a)Static means nothing, sum() is same without static keyword.b)Function need not to be declared before its usec)Access to static functions is restricted to the file where they are declaredd)Static functions are made inlineCorrect answer is option 'C'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice What is the meaning of using static before function declaration? For example following function sum is made staticstatic int sum(int x, int y, int z){ return (x + y + z);}a)Static means nothing, sum() is same without static keyword.b)Function need not to be declared before its usec)Access to static functions is restricted to the file where they are declaredd)Static functions are made inlineCorrect answer is option 'C'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev