C Programming - Declarations and Initializations - Discussion
Discussion Forum : Declarations and Initializations - General Questions (Q.No. 2)
2.
What are the types of linkages?
Answer: Option
Explanation:
External Linkage-> means global, non-static variables and functions.
Internal Linkage-> means static variables and functions with file scope.
None Linkage-> means Local variables.
Internal Linkage-> means static variables and functions with file scope.
None Linkage-> means Local variables.
Discussion:
95 comments Page 9 of 10.
Prathyusha said:
1 decade ago
//SATHISH explanation was correct!..
int main()
{
printf(" %d",root());
printf(" %d",root());
}
int root()
{
static int i;
i++;
return i;
}
BY DEFAULT ,ANY INTEGER OR STATIC INT VARIABLE VALUE IS ZERO.
BUT WHEN EACH TIME THE FUNCTION WAS CALLED ,THE DIFFERENCE OF NORMAL INT AND STATIC INT CAN BE SEEN.
IF THE "i" HERE IS NORMAL INTEGER IT WILL JUST RETURN ALWAYS VALUE "1" ,EVERY TIME IT IS CALLED .
BUT THE STATIC VARIABLE WILL HOLD PREVIOUS VALUES OF "i".EVERY TIME WHEN THE FUNCTION IS CALLED IT WILL THE PREVIOUS VALUES ARE RESTORED.
int main()
{
printf(" %d",root());
printf(" %d",root());
}
int root()
{
static int i;
i++;
return i;
}
BY DEFAULT ,ANY INTEGER OR STATIC INT VARIABLE VALUE IS ZERO.
BUT WHEN EACH TIME THE FUNCTION WAS CALLED ,THE DIFFERENCE OF NORMAL INT AND STATIC INT CAN BE SEEN.
IF THE "i" HERE IS NORMAL INTEGER IT WILL JUST RETURN ALWAYS VALUE "1" ,EVERY TIME IT IS CALLED .
BUT THE STATIC VARIABLE WILL HOLD PREVIOUS VALUES OF "i".EVERY TIME WHEN THE FUNCTION IS CALLED IT WILL THE PREVIOUS VALUES ARE RESTORED.
Prasanth reddy.d said:
1 decade ago
Can static variables be declared before main() ?
Silpi roy said:
1 decade ago
What are linkages?
Swetha said:
1 decade ago
Where do we use this linkages.
Arkadeep said:
1 decade ago
@satish-thanks a lot...but why the term linkage is used for this storage classes?
Swathy said:
1 decade ago
@shan and @komal
external - throughout the program
internal - a single file
none - local to a single function
external - throughout the program
internal - a single file
none - local to a single function
Sathish narasimman said:
1 decade ago
static example..
int main()
{
printf(" %d",root());
printf(" %d",root());
}
int root()
{
static int i;
i++;
return i;
}
it will print the updated value every time example: o/p=1 2 3 4...
where as if we use int i in the place of static int i, in the root function.. always print 1 1 1 1
int main()
{
printf(" %d",root());
printf(" %d",root());
}
int root()
{
static int i;
i++;
return i;
}
it will print the updated value every time example: o/p=1 2 3 4...
where as if we use int i in the place of static int i, in the root function.. always print 1 1 1 1
Vidvesh said:
1 decade ago
Tell me more about static variables???
Kaamani said:
1 decade ago
I want example program for three linkages.
Komal said:
1 decade ago
I wanna a briefly explain about the linkages.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers