C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - General Questions (Q.No. 8)
8.
Is the following statement a declaration or definition?
extern int i;
Declaration
Definition
Function
Error
Answer: Option
Explanation:

Declaring is the way a programmer tells the compiler to expect a particular type, be it a variable, class/struct/union type, a function type (prototype) or a particular object instance. (ie. extern int i)

Declaration never reserves any space for the variable or instance in the program's memory; it simply a "hint" to the compiler that a use of the variable or instance is expected in the program. This hinting is technically called "forward reference".

Discussion:
38 comments Page 3 of 4.

Niranjan said:   1 decade ago
@Ronak. error, we can't use static int x = i;

But we can use static int x = 10; or after declaring x use x = i;

RONAK said:   1 decade ago
Can we change the static value like :

int i=10;
static int x=i;

What is output please explain this?

Janani said:   1 decade ago
main()
{
extern int i;
i=20;
printf("%d",sizeof(i));
}
Output is error .please explain

Geetha said:   1 decade ago
Hey,whetr int i; is declaration or definition.
Dn, extern int i; is declaration or definition

BINDU said:   1 decade ago
What is the difference between declaration and definition ? please explain with examples?

Hiral said:   1 decade ago
What is difference between declaration, definition and initialization? Please help.

Shalini said:   1 decade ago
@Geetha int i is a declaration
i=10 is a definition.
int i=10 is a definition.

Appu said:   1 decade ago
int i=1;

This statement is definition or declaration ?

Anybody help me?

Rohith said:   8 years ago
Please tell me exact explanation of declaration and definition.

Priya said:   1 decade ago
What is the difference between declaration and definition?


Post your comments here:

Your comments will be displayed after verification.