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 4 of 4.

Naveen Dahiya said:   1 decade ago
I am not agree with Wikiok.

We also can not declare a user defined data type like any structure or union because the memory is also allocated to these (structures or unions) in the same way as it is assigned to any int or float variable.

Venky said:   1 decade ago
Let's consider file name is a1.c :

#include<stdio.h>
{
int i=10;
}


Then let us consider another file a2.c :

#include"a1.c"
#include<stdio.h>
main()
{
extern int i;
printf("%d\n",i);
}


Now this will print output is 10.

This is the right way how to use extern keyword.

Devendra said:   1 decade ago
What is meaning of prototype?

Pri said:   1 decade ago
It means some rules and regulations.

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

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

Princydhas said:   1 decade ago
int i=1;

This statement is definition or declaration ?

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


Post your comments here:

Your comments will be displayed after verification.