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;
extern int i;
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 1 of 4.
Hema said:
6 years ago
Give me clear information of extern.
(1)
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.
i=10 is a definition.
int i=10 is a definition.
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.
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.
BINDU said:
1 decade ago
What is the difference between declaration and definition ? please explain with examples?
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).
//variable
int i;//declaring
i=5;//defining
//method
void sum();//declaring
void sum()//defining
{
int a,b
printf("%f",a+b);
}
If a value is provided to variable and body is provided to function it is definition(same as common english word).
//variable
int i;//declaring
i=5;//defining
//method
void sum();//declaring
void sum()//defining
{
int a,b
printf("%f",a+b);
}
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?
int i=10;
static int x=i;
What is output please explain this?
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;
But we can use static int x = 10; or after declaring x use x = i;
Pranali said:
1 decade ago
For the word INDIRA how it can be char[7]?
Fajlurrahman said:
1 decade ago
@Pranali.
If the INDIRA is string then char[7]since INDIRA is string so we have to store extra memory location for null character.
If the INDIRA is string then char[7]since INDIRA is string so we have to store extra memory location for null character.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers