C Programming - Declarations and Initializations - Discussion

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

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".

38 comments Page 2 of 4.

Fajlurrahman said:   1 decade ago

If the INDIRA is string then char[7]since INDIRA is string so we have to store extra memory location for null character.

Pranali said:   1 decade ago
For the word INDIRA how it can be char[7]?

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?

Ragaveni said:   1 decade ago
If only name of variable or function is provided then it is declaration.

If a value is provided to variable and body is provided to function it is definition(same as common english word).

int i;//declaring
void sum();//declaring
void sum()//defining
int a,b

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

Studinstru said:   1 decade ago
What about static int a;.

As static int means its default value is consider as 0/zero only.

Then above statement is declaration or definition ?

This variable is stored in BSS section of memory.

Kernel make this variable as zero before program execution for arithmetic purpose.

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

Siji said:   1 decade ago
Whtr int i; is declaration or definition.
Dn external int i; is declaration or definition
Int i=10; is declaration or definition
External int i=10; is declaration or definition

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

Post your comments here:

Your comments will be displayed after verification.