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 2 of 10.
Arkadeep said:
1 decade ago
@satish-thanks a lot...but why the term linkage is used for this storage classes?
Swetha said:
1 decade ago
Where do we use this linkages.
Silpi roy said:
1 decade ago
What are linkages?
Prasanth reddy.d said:
1 decade ago
Can static variables be declared before main() ?
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.
Rajesh said:
1 decade ago
We declare already a static varible, in derived class we declare one more same static variable as declared first with different value, and call the previous variable,.......then.....Is the out put of program is first variable's value or secon variale's value...
Ram krishna said:
1 decade ago
I will thank full to Satish Narasimman and Prathyusa, who cleared my doubt.
Siri said:
1 decade ago
Good explanation pratyusha, thanq so much.
Saikiran said:
1 decade ago
What Prathyusha said is correct. That can be easily understood using this program.
#include<stdio.h>
int main()
{
printf("\n%d",funi());
printf("\n%d",funi());
printf("\n%d",funi());
printf("\n%d",funj());
printf("\n%d",funj());
printf("\n%d",funj());
//printf("\ni=%d\nj=%d",i,j);
return 0;
}
int funi()
{
int i;
i++;
return i;
}
int funj()
{
static int j;
j++;
return j;
}
output:
1
1
1
1
2
3
#include<stdio.h>
int main()
{
printf("\n%d",funi());
printf("\n%d",funi());
printf("\n%d",funi());
printf("\n%d",funj());
printf("\n%d",funj());
printf("\n%d",funj());
//printf("\ni=%d\nj=%d",i,j);
return 0;
}
int funi()
{
int i;
i++;
return i;
}
int funj()
{
static int j;
j++;
return j;
}
output:
1
1
1
1
2
3
Gaurav said:
1 decade ago
x= 5;
z = ++x + ++x ;
cout<<z;
why does this display 14 , instead of 13 ?
z = ++x + ++x ;
cout<<z;
why does this display 14 , instead of 13 ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers