What is the difference between a declaration and a definition of a variable?
A. Both can occur multiple times, but a declaration must occur first.
B. A definition occurs once, but a declaration may occur many times.
C. Both can occur multiple times, but a definition must occur first.
D. A declaration occurs once, but a definition may occur many times.
E. There is no difference between them.
Answer: Option D
Join The Discussion
Comments ( 14 )
Related Questions on C Fundamentals
What is the primary purpose of a function prototype in C?
A. Declare a variable
B. Declare a function
C. Define a function
D. Assign a value
What is the correct syntax for declaring a variable in C?
A. int variable_name;
B. variable_name = 5;
C. variable_name int;
D. int = variable_name;
Correct ans is D
Int ino;
ino =10;
ino. =20;
A variable or function can be declaired many no of times, a defination can be define one time.
Yes ! The answer given is incorrect. The correct answer is Option B
What is definition
The declaration could be done multiple times either of a variable or of function.
Variable or function could be defined only once.
Its wrong
int main()
{
int a;
a=10;
{
int a;
a=1000;
printf("%d",a);
}
printf("% d",a);
}
o/p
1000 10
void main()
{
ans is b not d
declaration can be done many time but defination only once
answer for above question is B not D
thanks madhura and ayesha!
A declaration occurs once,but a definition may occur many times.Explain,I cannot understand this.
Declaration of variable mean to tell compiler their is a varfunctstruct of particular data type. Definition of variable mean asking compiler to allocate memory to variable or define storage for that variable. you can define a variable only one time but you can declare it as many time you want.
intially we declare the variable then we use dafination
plz explain