In C, static storage class cannot be used with: a. Global variable b. Function parameter c. Function name d. Local variable
Question
In C, static storage class cannot be used with:
a. Global variable
b. Function parameter
c. Function name
d. Local variable
Solution
Break Down the Problem
- Identify Static Storage Class: Understand the context and usage of the static storage class in C.
- Evaluate Each Option: Analyze each provided option to determine if static can be used with it.
Relevant Concepts
- The static storage class in C indicates that the variable's lifetime is the entire duration of the program and retains its value between function calls.
- It can be applied to local variables, global variables, and functions, but it has restrictions.
Analysis and Detail
-
Global Variable: The static keyword can be used; it limits the variable's scope to the file containing it.
-
Function Parameter: The static keyword cannot be applied to function parameters. Function parameters are created on the stack and are only active during the function call duration.
-
Function Name: While you can have static functions (making the function only visible within the file), it does not apply to the function name in the same way as variables.
-
Local Variable: You can use static with local variables; they retain their value even after the function exits.
Verify and Summarize
After analyzing each option:
- Option b (Function parameter) is the correct answer, as static cannot be used with function parameters.
Final Answer
The correct answer is: b. Function parameter.
Similar Questions
BasicsWhat is storage class for variable A in below code?void main() { int A; A = 10; printf("%d", A);}Optionsautoexternregisterstatic
Which among the following is a Local Variable.?a.registerb.autoc.staticd.extern
Which of the following correctly describes the scope of a variable declared inside a function?Global scopeLocal scope to the functionStatic scopeFile scope
orrect answerDefault storage class of a variable is ________Optionsautoexternstaticregister
Which of the following is not a storage class specifier in C?a.Registerb.Automaticc.volatiled.External
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.