Knowee
Questions
Features
Study Tools

BasicsWhat is storage class for variable A in below code?void main() { int A; A = 10; printf("%d", A);}Optionsautoexternregisterstatic

Question

What is storage class for variable A in below code?

void main() { 
	int A;  
	A = 10;  
	printf("%d", A); 
}

Options

  • auto
  • extern
  • register
  • static
🧐 Not the exact question you are looking for?Go ask a question

Solution

Break Down the Problem

  1. Identify the context in which the variable A is declared.
  2. Determine the default storage class for the variable based on its declaration and scope.

Relevant Concepts

  1. Storage Classes in C: There are several storage classes in C:
    • auto: Default for local variables, storage is allocated when the block is entered and freed when it exits.
    • extern: Specifies that a variable is defined in another file or scope.
    • register: Indicates that the variable is to be stored in a register of the CPU for faster access.
    • static: Retains the value of the variable between function calls and restricts its scope to the file or function.

Analysis and Detail

  1. In the provided code, A is declared within the main function. Since it is not prefixed by any storage class specifier, it defaults to auto.
  2. The variable A has local scope, created when main starts and destroyed when main ends.

Verify and Summarize

Since there are no external qualifiers or attributes modifying A, it confirms the default storage class.

Final Answer

The storage class for variable A in the given code is auto.

This problem has been solved

Similar Questions

sicsWhat is storage class for variable A in below code?void main() { int A; A = 10; printf("%d", A);}

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

Which among the following is a Local Variable.?a.registerb.autoc.staticd.extern

Local variables are stored in an area called ___________OptionsPermanent storage areaHeapFree memoryStack

1/1

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.